using System;
namespace MicroMsg.Common.Audio.Amr
{
	public class GloabFunc
	{
		public class Pre_ProcessState
		{
			public float float_0;
			public float float_1;
			public float float_2;
			public float float_3;
			public Pre_ProcessState()
			{
				this.float_0 = 0f;
				this.float_1 = 0f;
				this.float_2 = 0f;
				this.float_3 = 0f;
			}
		}
		public class vadState
		{
			public float pre_emp_mem;
			public short update_cnt;
			public short hyster_cnt;
			public short last_update_cnt;
			public float[] ch_enrg_long_db;
			public int Lframe_cnt;
			public float[] ch_enrg;
			public float[] ch_noise;
			public float tsnr;
			public short hangover;
			public short burstcount;
			public short fupdate_flag;
			public float negSNRvar;
			public float negSNRbias;
			public float R0;
			public float Rmax;
			public short LTP_flag;
			public vadState()
			{
				this.pre_emp_mem = 0f;
				this.update_cnt = 0;
				this.hyster_cnt = 0;
				this.last_update_cnt = 0;
				this.Lframe_cnt = 0;
				this.tsnr = 0f;
				this.hangover = 0;
				this.burstcount = 0;
				this.fupdate_flag = 0;
				this.negSNRvar = 0f;
				this.negSNRbias = 0f;
				this.R0 = 0f;
				this.Rmax = 0f;
				this.LTP_flag = 0;
				this.ch_enrg_long_db = new float[16];
				this.ch_enrg = new float[16];
				this.ch_noise = new float[16];
			}
		}
		public class dtx_encState
		{
			public float[] lsp_hist;
			public float[] log_en_hist;
			public int init_lsf_vq_index;
			public short hist_ptr;
			public short log_en_index;
			public short[] lsp_index;
			public short dtxHangoverCount;
			public short decAnaElapsedCount;
			public dtx_encState()
			{
				this.lsp_hist = new float[80];
				this.log_en_hist = new float[8];
				this.lsp_index = new short[3];
				this.init_lsf_vq_index = 0;
				this.hist_ptr = 0;
				this.log_en_index = 0;
				this.dtxHangoverCount = 0;
				this.decAnaElapsedCount = 0;
			}
		}
		public class tonStabState
		{
			public float[] float_0;
			public short count;
			public tonStabState()
			{
				this.count = 0;
				this.float_0 = new float[7];
			}
		}
		public class gc_predState
		{
			public int[] past_qua_en;
			public gc_predState()
			{
				this.past_qua_en = new int[4];
			}
		}
		public class gain_adaptState
		{
			public float prev_alpha;
			public float prev_gc;
			public float[] ltpg_mem;
			public short onset;
			public gain_adaptState()
			{
				this.prev_alpha = 0f;
				this.prev_gc = 0f;
				this.ltpg_mem = new float[5];
				this.onset = 0;
			}
		}
		public class gainQuantState
		{
			public float sf0_target_en;
			public float[] sf0_coeff;
			public int sf0_gcode0_exp;
			public int sf0_gcode0_fra;
			public short[] gain_idx_ptr;
			public int gain_idx_ptrOffset;
			public GloabFunc.gc_predState gc_predSt;
			public GloabFunc.gc_predState gc_predUncSt;
			public GloabFunc.gain_adaptState adaptSt;
			public gainQuantState()
			{
				this.gain_idx_ptr = null;
				this.gain_idx_ptrOffset = 0;
				this.sf0_target_en = 0f;
				this.sf0_coeff = new float[5];
				this.sf0_gcode0_exp = 0;
				this.sf0_gcode0_fra = 0;
				this.gain_idx_ptr = null;
				this.gc_predSt = null;
				this.gc_predUncSt = null;
				this.adaptSt = null;
			}
		}
		public class Pitch_frState
		{
			public int T0_prev_subframe;
		}
		public class clLtpState
		{
			public GloabFunc.Pitch_frState pitchSt;
			public clLtpState()
			{
				this.pitchSt = null;
			}
		}
		public class pitchOLWghtState
		{
			public float ada_w;
			public int old_T0_med;
			public short wght_flg;
		}
		public class Q_plsfState
		{
			public float[] past_rq;
			public Q_plsfState()
			{
				this.past_rq = new float[10];
			}
		}
		public class lspState
		{
			public float[] lsp_old;
			public float[] lsp_old_q;
			public GloabFunc.Q_plsfState qSt;
			public lspState()
			{
				this.lsp_old = new float[10];
				this.lsp_old_q = new float[10];
				this.qSt = null;
			}
		}
		public class LevinsonState
		{
			public float[] old_A;
			public LevinsonState()
			{
				this.old_A = new float[11];
			}
		}
		public class lpcState
		{
			public GloabFunc.LevinsonState LevinsonSt;
		}
		public class cod_amrState
		{
			public float[] old_speech;
			public float[] speech;
			public int speechOffset;
			public float[] p_window;
			public int p_windowOffset;
			public float[] p_window_12k2;
			public int p_window_12k2Offset;
			public float[] new_speech;
			public int new_speechOffset;
			public float[] old_wsp;
			public float[] float_0;
			public int wspOffset;
			public int[] old_lags;
			public float[] ol_gain_flg;
			public float[] old_exc;
			public float[] float_1;
			public int excOffset;
			public float[] ai_zero;
			public float[] zero;
			public int zeroOffset;
			public float[] float_2;
			public int h1Offset;
			public float[] hvec;
			public GloabFunc.lpcState lpcSt;
			public GloabFunc.lspState lspSt;
			public GloabFunc.clLtpState clLtpSt;
			public GloabFunc.gainQuantState gainQuantSt;
			public GloabFunc.pitchOLWghtState pitchOLWghtSt;
			public GloabFunc.tonStabState tonStabSt;
			public GloabFunc.vadState vadSt;
			public int int_0;
			public GloabFunc.dtx_encState dtxEncSt;
			public float[] mem_syn;
			public float[] mem_w0;
			public float[] mem_w;
			public float[] mem_err;
			public float[] error;
			public int errorOffset;
			public float sharp;
			public cod_amrState()
			{
				this.old_speech = new float[320];
				this.old_wsp = new float[303];
				this.wspOffset = 0;
				this.old_lags = new int[5];
				this.ol_gain_flg = new float[2];
				this.old_exc = new float[314];
				this.excOffset = 0;
				this.ai_zero = new float[51];
				this.zeroOffset = 0;
				this.h1Offset = 0;
				this.hvec = new float[80];
				this.mem_syn = new float[10];
				this.mem_w0 = new float[10];
				this.mem_w = new float[10];
				this.mem_err = new float[50];
				this.errorOffset = 0;
			}
		}
		public class Speech_Encode_FrameState
		{
			public GloabFunc.cod_amrState cod_amr_state;
			public GloabFunc.Pre_ProcessState pre_state;
			public int int_0;
			public Speech_Encode_FrameState()
			{
				this.cod_amr_state = null;
				this.pre_state = null;
				this.int_0 = 0;
			}
		}
		public const int DTX_HIST_SIZE = 8;
		public const int DTX_ELAPSED_FRAMES_THRESH = 30;
		public const int DTX_HANG_CONST = 7;
		private static int[,] ch_tbl = new int[,]
		{

			{
				2,
				3
			},

			{
				4,
				5
			},

			{
				6,
				7
			},

			{
				8,
				9
			},

			{
				10,
				11
			},

			{
				12,
				13
			},

			{
				14,
				16
			},

			{
				17,
				19
			},

			{
				20,
				22
			},

			{
				23,
				26
			},

			{
				27,
				30
			},

			{
				31,
				35
			},

			{
				36,
				41
			},

			{
				42,
				48
			},

			{
				49,
				55
			},

			{
				56,
				63
			}
		};
		private static int[] vm_tbl = new int[]
		{
			2,
			2,
			2,
			2,
			2,
			2,
			2,
			2,
			2,
			2,
			2,
			3,
			3,
			3,
			3,
			3,
			4,
			4,
			4,
			5,
			5,
			5,
			6,
			6,
			7,
			7,
			7,
			8,
			8,
			9,
			9,
			10,
			10,
			11,
			12,
			12,
			13,
			13,
			14,
			15,
			15,
			16,
			17,
			17,
			18,
			19,
			20,
			20,
			21,
			22,
			23,
			24,
			24,
			25,
			26,
			27,
			28,
			28,
			29,
			30,
			31,
			32,
			33,
			34,
			35,
			36,
			37,
			37,
			38,
			39,
			40,
			41,
			42,
			43,
			44,
			45,
			46,
			47,
			48,
			49,
			50,
			50,
			50,
			50,
			50,
			50,
			50,
			50,
			50,
			50
		};
		private static short[] hangover_table = new short[]
		{
			30,
			30,
			30,
			30,
			30,
			30,
			28,
			26,
			24,
			22,
			20,
			18,
			16,
			14,
			12,
			10,
			8,
			8,
			8,
			8
		};
		private static short[] burstcount_table = new short[]
		{
			8,
			8,
			8,
			8,
			8,
			8,
			8,
			8,
			7,
			6,
			5,
			4,
			4,
			4,
			4,
			4,
			4,
			4,
			4,
			4
		};
		private static short[] vm_threshold_table = new short[]
		{
			34,
			34,
			34,
			34,
			34,
			34,
			34,
			34,
			34,
			34,
			34,
			40,
			51,
			71,
			100,
			139,
			191,
			257,
			337,
			432
		};
		private static double[] phs_tbl = new double[128];
		private static int first = 1;
		private static short sign
		{
			set
			{
				int num = 0;
				for (int i = 0; i < 40; i++)
				{
					float num2 = float_0[dnOffset + i];
					if (num2 >= 0f)
					{
						sign[signOffset + i] = 1f;
					}
					else
					{
						sign[signOffset + i] = -1f;
						num2 = -num2;
					}
					float_0[dnOffset + i] = num2;
					float_1[dn2Offset + i] = num2;
				}
				for (int i = 0; i < 5; i++)
				{
					for (int j = 0; j < (int)(8 - value); j++)
					{
						float num3 = 3.40282347E+38f;
						for (int k = i; k < 40; k += 5)
						{
							if (float_1[dn2Offset + k] >= 0f)
							{
								float num2 = float_1[dn2Offset + k] - num3;
								if (num2 < 0f)
								{
									num3 = float_1[dn2Offset + k];
									num = k;
								}
							}
						}
						float_1[dn2Offset + num] = -1f;
					}
				}
			}
		}
		private static short sign12k2
		{
			set
			{
				float[] array = new float[40];
				int num = 0;
				float num2 = 0.01f;
				num2 += GloabFunc.Dotproduct40(float_1, cnOffset, float_1, cnOffset);
				float num3 = (float)(1.0 / Math.Sqrt((double)num2));
				num2 = 0.01f;
				num2 += GloabFunc.Dotproduct40(float_0, dnOffset, float_0, dnOffset);
				float num4 = (float)(1.0 / Math.Sqrt((double)num2));
				for (int i = 0; i < 40; i++)
				{
					float num5 = float_0[dnOffset + i];
					float num6 = num3 * float_1[cnOffset + i] + num4 * num5;
					sign[signOffset + i] = 1f;
					if (num6 < 0f)
					{
						sign[signOffset + i] = -1f;
						num6 = -num6;
						num5 = -num5;
					}
					float_0[dnOffset + i] = num5;
					array[i] = num6;
				}
				float num7 = -1f;
				for (int i = 0; i < (int)nb_track; i++)
				{
					float num8 = -1f;
					float num5;
					for (int j = i; j < 40; j += (int)value)
					{
						float num6 = array[j];
						num5 = num6 - num8;
						if (num5 > 0f)
						{
							num8 = num6;
							num = j;
						}
					}
					pos_max[pos_maxOffset + i] = num;
					num5 = num8 - num7;
					if (num5 > 0f)
					{
						num7 = num8;
						ipos[iposOffset] = i;
					}
				}
				num = ipos[iposOffset];
				ipos[iposOffset + (int)nb_track] = num;
				for (int i = 1; i < (int)nb_track; i++)
				{
					num++;
					if (num >= (int)nb_track)
					{
						num = 0;
					}
					ipos[iposOffset + i] = num;
					ipos[iposOffset + i + (int)nb_track] = num;
				}
			}
		}
		public static Mode DecoderMMS(short[] param, int paramOffset, byte[] stream, int streamOffset, ref RXFrameType frame_type, ref Mode speech_mode, ref short q_bit)
		{
			int num = 0;
			GloabFunc.memsetShort(param, paramOffset, 0, 114);
			q_bit = (short)(1 & stream[streamOffset] >> 2);
			int num2 = 15 & stream[streamOffset] >> 3;
			streamOffset++;
			if (num2 == 8)
			{
				short[] array = DefineConstants.order_MRDTX;
				for (long num3 = 1L; num3 < 36L; num3 += 1L)
				{
					if ((stream[streamOffset] & 128) != 0)
					{
						param[(int)array[num] + paramOffset] = param[(int)array[num] + paramOffset] + array[num + 1];
					}
					num += 2;
					if (num3 % 8L != 0L)
					{
						int expr_6F_cp_1 = streamOffset;
						stream[expr_6F_cp_1] = (byte)(stream[expr_6F_cp_1] << 1);
					}
					else
					{
						streamOffset++;
					}
				}
				frame_type = RXFrameType.RX_SID_FIRST;
				if ((stream[streamOffset] & 128) != 0)
				{
					frame_type = RXFrameType.RX_SID_UPDATE;
				}
				speech_mode = ((stream[streamOffset] >> 4 != 0) ? Mode.MR515 : Mode.MR475);
			}
			else
			{
				if (num2 == 15)
				{
					frame_type = RXFrameType.RX_NO_DATA;
				}
				else
				{
					if (num2 == 0)
					{
						short[] array = DefineConstants.order_MR475;
						for (long num3 = 1L; num3 < 96L; num3 += 1L)
						{
							if ((stream[streamOffset] & 128) != 0)
							{
								param[(int)array[num] + paramOffset] = param[(int)array[num] + paramOffset] + array[num + 1];
							}
							num += 2;
							if (num3 % 8L != 0L)
							{
								int expr_104_cp_1 = streamOffset;
								stream[expr_104_cp_1] = (byte)(stream[expr_104_cp_1] << 1);
							}
							else
							{
								streamOffset++;
							}
						}
						frame_type = RXFrameType.RX_SPEECH_GOOD;
					}
					else
					{
						if (num2 == 1)
						{
							short[] array = DefineConstants.order_MR515;
							for (long num3 = 1L; num3 < 104L; num3 += 1L)
							{
								if ((stream[streamOffset] & 128) != 0)
								{
									param[(int)array[num] + paramOffset] = param[(int)array[num] + paramOffset] + array[num + 1];
								}
								num += 2;
								if (num3 % 8L != 0L)
								{
									int expr_16F_cp_1 = streamOffset;
									stream[expr_16F_cp_1] = (byte)(stream[expr_16F_cp_1] << 1);
								}
								else
								{
									streamOffset++;
								}
							}
							frame_type = RXFrameType.RX_SPEECH_GOOD;
						}
						else
						{
							if (num2 == 2)
							{
								short[] array = DefineConstants.order_MR59;
								for (long num3 = 1L; num3 < 119L; num3 += 1L)
								{
									if ((stream[streamOffset] & 128) != 0)
									{
										param[(int)array[num] + paramOffset] = param[(int)array[num] + paramOffset] + array[num + 1];
									}
									num += 2;
									if (num3 % 8L != 0L)
									{
										int expr_1DA_cp_1 = streamOffset;
										stream[expr_1DA_cp_1] = (byte)(stream[expr_1DA_cp_1] << 1);
									}
									else
									{
										streamOffset++;
									}
								}
								frame_type = RXFrameType.RX_SPEECH_GOOD;
							}
							else
							{
								if (num2 == 3)
								{
									short[] array = DefineConstants.order_MR67;
									for (long num3 = 1L; num3 < 135L; num3 += 1L)
									{
										if ((stream[streamOffset] & 128) != 0)
										{
											param[(int)array[num] + paramOffset] = param[(int)array[num] + paramOffset] + array[num + 1];
										}
										num += 2;
										if (num3 % 8L != 0L)
										{
											int expr_245_cp_1 = streamOffset;
											stream[expr_245_cp_1] = (byte)(stream[expr_245_cp_1] << 1);
										}
										else
										{
											streamOffset++;
										}
									}
									frame_type = RXFrameType.RX_SPEECH_GOOD;
								}
								else
								{
									if (num2 == 4)
									{
										short[] array = DefineConstants.order_MR74;
										for (long num3 = 1L; num3 < 149L; num3 += 1L)
										{
											if ((stream[streamOffset] & 128) != 0)
											{
												param[(int)array[num] + paramOffset] = param[(int)array[num] + paramOffset] + array[num + 1];
											}
											num += 2;
											if (num3 == 144L)
											{
												num3 = 144L;
											}
											if (num3 % 8L != 0L)
											{
												int expr_2C3_cp_1 = streamOffset;
												stream[expr_2C3_cp_1] = (byte)(stream[expr_2C3_cp_1] << 1);
											}
											else
											{
												streamOffset++;
											}
										}
										frame_type = RXFrameType.RX_SPEECH_GOOD;
									}
									else
									{
										if (num2 == 5)
										{
											short[] array = DefineConstants.order_MR795;
											for (long num3 = 1L; num3 < 160L; num3 += 1L)
											{
												if ((stream[streamOffset] & 128) != 0)
												{
													param[(int)array[num] + paramOffset] = param[(int)array[num] + paramOffset] + array[num + 1];
												}
												num += 2;
												if (num3 % 8L != 0L)
												{
													int expr_331_cp_1 = streamOffset;
													stream[expr_331_cp_1] = (byte)(stream[expr_331_cp_1] << 1);
												}
												else
												{
													streamOffset++;
												}
											}
											frame_type = RXFrameType.RX_SPEECH_GOOD;
										}
										else
										{
											if (num2 == 6)
											{
												short[] array = DefineConstants.order_MR102;
												for (long num3 = 1L; num3 < 205L; num3 += 1L)
												{
													if ((stream[streamOffset] & 128) != 0)
													{
														param[(int)array[num] + paramOffset] = param[(int)array[num] + paramOffset] + array[num + 1];
													}
													num += 2;
													if (num3 % 8L != 0L)
													{
														int expr_39F_cp_1 = streamOffset;
														stream[expr_39F_cp_1] = (byte)(stream[expr_39F_cp_1] << 1);
													}
													else
													{
														streamOffset++;
													}
												}
												frame_type = RXFrameType.RX_SPEECH_GOOD;
											}
											else
											{
												if (num2 == 7)
												{
													short[] array = DefineConstants.order_MR122;
													for (long num3 = 1L; num3 < 245L; num3 += 1L)
													{
														if ((stream[streamOffset] & 128) != 0)
														{
															param[(int)array[num] + paramOffset] = param[(int)array[num] + paramOffset] + array[num + 1];
														}
														num += 2;
														if (num3 % 8L != 0L)
														{
															int expr_40A_cp_1 = streamOffset;
															stream[expr_40A_cp_1] = (byte)(stream[expr_40A_cp_1] << 1);
														}
														else
														{
															streamOffset++;
														}
													}
													frame_type = RXFrameType.RX_SPEECH_GOOD;
												}
												else
												{
													frame_type = RXFrameType.RX_SPEECH_BAD;
												}
											}
										}
									}
								}
							}
						}
					}
				}
			}
			return (Mode)num2;
		}
		private static void Decoder_Interface_reset(dec_interface_State dec_interface_State_0)
		{
			dec_interface_State_0.reset_flag_old = 1;
			dec_interface_State_0.prev_ft = RXFrameType.RX_SPEECH_GOOD;
			dec_interface_State_0.prev_mode = Mode.MR475;
		}
		public static object Decoder_Interface_init()
		{
			dec_interface_State dec_interface_State = new dec_interface_State();
			dec_interface_State.decoder_State = GloabFunc_Dec.Speech_Decode_Frame_init();
			if (dec_interface_State.decoder_State == null)
			{
				return null;
			}
			GloabFunc.Decoder_Interface_reset(dec_interface_State);
			return dec_interface_State;
		}
		public static void Decoder_Interface_exit(object state)
		{
			dec_interface_State dec_interface_State = (dec_interface_State)state;
			GloabFunc_Dec.Speech_Decode_Frame_exit(dec_interface_State.decoder_State);
			state = null;
		}
		public static void Decoder_Interface_Decode(object object_0, byte[] bits, int bitsOffset, short[] synth, int synthOffset, int int_0)
		{
			Mode mode = Mode.MR475;
			short[] array = new short[57];
			int num = 0;
			RXFrameType rXFrameType = RXFrameType.RX_SPEECH_GOOD;
			int num2 = 0;
			long num3 = 1L;
			short num4 = 0;
			dec_interface_State dec_interface_State = (dec_interface_State)object_0;
			Mode mode2 = GloabFunc.DecoderMMS(array, 0, bits, bitsOffset, ref rXFrameType, ref mode, ref num4);
			if (int_0 == 0)
			{
				int_0 = (int)(1 - num4);
			}
			if (int_0 == 1)
			{
				if (mode2 <= Mode.MR122)
				{
					rXFrameType = RXFrameType.RX_SPEECH_BAD;
				}
				else
				{
					if (rXFrameType != RXFrameType.RX_NO_DATA)
					{
						rXFrameType = RXFrameType.RX_SID_BAD;
						mode2 = dec_interface_State.prev_mode;
					}
				}
			}
			else
			{
				if (rXFrameType != RXFrameType.RX_SID_FIRST)
				{
					if (rXFrameType != RXFrameType.RX_SID_UPDATE)
					{
						if (rXFrameType == RXFrameType.RX_NO_DATA)
						{
							mode2 = dec_interface_State.prev_mode;
							goto IL_7A;
						}
						goto IL_7A;
					}
				}
				mode2 = mode;
				IL_7A:
				if (rXFrameType == RXFrameType.RX_SPEECH_BAD)
				{
					mode2 = dec_interface_State.prev_mode;
					if (dec_interface_State.prev_ft >= RXFrameType.RX_SID_FIRST)
					{
						rXFrameType = RXFrameType.RX_SID_BAD;
					}
				}
			}
			if (dec_interface_State.reset_flag_old == 1)
			{
				short[] array2;
				short num5;
				switch (mode2)
				{
				case Mode.MR475:
					array2 = DefineConstants.dhf_MR475;
					num5 = 7;
					break;
				case Mode.MR515:
					array2 = DefineConstants.dhf_MR515;
					num5 = 7;
					break;
				case Mode.MR59:
					array2 = DefineConstants.dhf_MR59;
					num5 = 7;
					break;
				case Mode.MR67:
					array2 = DefineConstants.dhf_MR67;
					num5 = 7;
					break;
				case Mode.MR74:
					array2 = DefineConstants.dhf_MR74;
					num5 = 7;
					break;
				case Mode.MR795:
					array2 = DefineConstants.dhf_MR795;
					num5 = 8;
					break;
				case Mode.MR102:
					array2 = DefineConstants.dhf_MR102;
					num5 = 12;
					break;
				case Mode.MR122:
					array2 = DefineConstants.dhf_MR122;
					num5 = 18;
					break;
				default:
					array2 = null;
					num5 = 0;
					break;
				}
				for (long num6 = 0L; num6 < (long)num5; num6 += 1L)
				{
					num3 = (long)checked(array[(int)((IntPtr)unchecked((long)num + num6))] ^ array2[(int)((IntPtr)unchecked((long)num2 + num6))]);
					if (num3 != 0L)
					{
						break;
					}
				}
			}
			if (num3 == 0L && dec_interface_State.reset_flag_old != 0)
			{
				for (long num6 = 0L; num6 < 160L; num6 += 1L)
				{
					synth[(int)checked((IntPtr)num6)] = 8;
				}
			}
			else
			{
				GloabFunc_Dec.Speech_Decode_Frame(dec_interface_State.decoder_State, mode2, array, num, rXFrameType, synth, synthOffset);
			}
			if (dec_interface_State.reset_flag_old == 0)
			{
				short[] array2;
				short num5;
				switch (mode2)
				{
				case Mode.MR475:
					array2 = DefineConstants.dhf_MR475;
					num5 = 17;
					break;
				case Mode.MR515:
					array2 = DefineConstants.dhf_MR515;
					num5 = 19;
					break;
				case Mode.MR59:
					array2 = DefineConstants.dhf_MR59;
					num5 = 19;
					break;
				case Mode.MR67:
					array2 = DefineConstants.dhf_MR67;
					num5 = 19;
					break;
				case Mode.MR74:
					array2 = DefineConstants.dhf_MR74;
					num5 = 19;
					break;
				case Mode.MR795:
					array2 = DefineConstants.dhf_MR795;
					num5 = 23;
					break;
				case Mode.MR102:
					array2 = DefineConstants.dhf_MR102;
					num5 = 39;
					break;
				case Mode.MR122:
					array2 = DefineConstants.dhf_MR122;
					num5 = 57;
					break;
				default:
					array2 = null;
					num5 = 0;
					break;
				}
				for (long num6 = 0L; num6 < (long)num5; num6 += 1L)
				{
					num3 = (long)checked(array[(int)((IntPtr)num6)] ^ array2[(int)((IntPtr)num6)]);
					if (num3 != 0L)
					{
						break;
					}
				}
			}
			if (num3 == 0L)
			{
				GloabFunc_Dec.Speech_Decode_Frame_reset(dec_interface_State.decoder_State);
			}
			dec_interface_State.reset_flag_old = GloabFunc.bool2int(num3 == 0L);
			dec_interface_State.prev_ft = rXFrameType;
			dec_interface_State.prev_mode = mode2;
		}
		public static void short_copy(short[] from, int fromOffset, int int_0, int int_1, short[] short_0, int toOffset)
		{
			for (int i = 0; i < int_1; i++)
			{
				short_0[i + toOffset] = from[int_0 + i + fromOffset];
			}
		}
		public static void memcpy(byte[] byte_0, int dstoffset, byte[] byte_1, int srcoffset, int int_0)
		{
			for (int i = 0; i < int_0; i++)
			{
				byte_0[dstoffset + i] = byte_1[srcoffset + i];
			}
		}
		public static void memcpyFloat(float[] float_0, int dstoffset, float[] float_1, int srcoffset, int int_0)
		{
			for (int i = 0; i < int_0; i++)
			{
				float_0[dstoffset + i] = float_1[srcoffset + i];
			}
		}
		public static void memcpyInt(int[] int_0, int dstoffset, int[] int_1, int srcoffset, int int_2)
		{
			for (int i = 0; i < int_2; i++)
			{
				int_0[dstoffset + i] = int_1[srcoffset + i];
			}
		}
		public static void memset(byte[] byte_0, int offset, byte newValue, int int_0)
		{
			for (int i = 0; i < int_0; i++)
			{
				byte_0[offset + i] = newValue;
			}
		}
		public static void memsetShort(short[] short_0, int offset, short newValue, int bytelen)
		{
			int num = bytelen / 2;
			for (int i = 0; i < num; i++)
			{
				short_0[offset + i] = newValue;
			}
		}
		public static void memsetFloat(float[] float_0, int offset, float newValue, int bytelen)
		{
			int num = bytelen / 4;
			for (int i = 0; i < num; i++)
			{
				float_0[offset + i] = newValue;
			}
		}
		public static void memsetInt(int[] int_0, int offset, int newValue, int bytelen)
		{
			int num = bytelen / 4;
			for (int i = 0; i < num; i++)
			{
				int_0[offset + i] = newValue;
			}
		}
		public static int bool2int(bool input)
		{
			return input ? 1 : 0;
		}
		public static int EncoderMMS(Mode mode, short[] param, byte[] stream, TXFrameType frame_type, Mode speech_mode)
		{
			int i = 0;
			GloabFunc.memset(stream, 0, 0, (int)DefineConstants.block_size[(int)mode]);
			stream[0] = DefineConstants.toc_byte[(int)mode];
			int num = 0 + 1;
			if (mode == (Mode)15)
			{
				return 1;
			}
			if (mode == Mode.MRDTX)
			{
				short[] array = DefineConstants.order_MRDTX;
				int num2 = 0;
				for (i = 1; i < 36; i++)
				{
					if ((param[(int)array[num2]] & array[num2 + 1]) != 0)
					{
						int expr_51_cp_1 = num;
						stream[expr_51_cp_1] += 1;
					}
					num2 += 2;
					if (i % 8 != 0)
					{
						int expr_6F_cp_1 = num;
						stream[expr_6F_cp_1] = (byte)(stream[expr_6F_cp_1] << 1);
					}
					else
					{
						num++;
					}
				}
				if (frame_type == TXFrameType.TX_SID_UPDATE)
				{
					int expr_97_cp_1 = num;
					stream[expr_97_cp_1] += 1;
				}
				int expr_AC_cp_1 = num;
				stream[expr_AC_cp_1] = (byte)(stream[expr_AC_cp_1] << 3);
				int expr_C1_cp_1 = num;
				stream[expr_C1_cp_1] += (byte)(speech_mode & Mode.MR122);
				int expr_DA_cp_1 = num;
				stream[expr_DA_cp_1] = (byte)(stream[expr_DA_cp_1] << 1);
				return 6;
			}
			if (mode == Mode.MR475)
			{
				short[] array = DefineConstants.order_MR475;
				int num2 = 0;
				for (i = 1; i < 96; i++)
				{
					if ((param[(int)array[num2]] & array[num2 + 1]) != 0)
					{
						int expr_10D_cp_1 = num;
						stream[expr_10D_cp_1] += 1;
					}
					num2 += 2;
					if (i % 8 != 0)
					{
						int expr_12B_cp_1 = num;
						stream[expr_12B_cp_1] = (byte)(stream[expr_12B_cp_1] << 1);
					}
					else
					{
						num++;
					}
				}
			}
			else
			{
				if (mode == Mode.MR515)
				{
					short[] array = DefineConstants.order_MR515;
					int num2 = 0;
					for (i = 1; i < 104; i++)
					{
						if ((param[(int)array[num2]] & array[num2 + 1]) != 0)
						{
							int expr_171_cp_1 = num;
							stream[expr_171_cp_1] += 1;
						}
						num2 += 2;
						if (i % 8 != 0)
						{
							int expr_18F_cp_1 = num;
							stream[expr_18F_cp_1] = (byte)(stream[expr_18F_cp_1] << 1);
						}
						else
						{
							num++;
						}
					}
				}
				else
				{
					if (mode == Mode.MR59)
					{
						short[] array = DefineConstants.order_MR59;
						int num2 = 0;
						for (i = 1; i < 119; i++)
						{
							if ((param[(int)array[num2]] & array[num2 + 1]) != 0)
							{
								int expr_1D5_cp_1 = num;
								stream[expr_1D5_cp_1] += 1;
							}
							num2 += 2;
							if (i % 8 != 0)
							{
								int expr_1F3_cp_1 = num;
								stream[expr_1F3_cp_1] = (byte)(stream[expr_1F3_cp_1] << 1);
							}
							else
							{
								num++;
							}
						}
					}
					else
					{
						if (mode == Mode.MR67)
						{
							short[] array = DefineConstants.order_MR67;
							int num2 = 0;
							for (i = 1; i < 135; i++)
							{
								if ((param[(int)array[num2]] & array[num2 + 1]) != 0)
								{
									int expr_239_cp_1 = num;
									stream[expr_239_cp_1] += 1;
								}
								num2 += 2;
								if (i % 8 != 0)
								{
									int expr_257_cp_1 = num;
									stream[expr_257_cp_1] = (byte)(stream[expr_257_cp_1] << 1);
								}
								else
								{
									num++;
								}
							}
						}
						else
						{
							if (mode == Mode.MR74)
							{
								short[] array = DefineConstants.order_MR74;
								int num2 = 0;
								for (i = 1; i < 149; i++)
								{
									if ((param[(int)array[num2]] & array[num2 + 1]) != 0)
									{
										int expr_2A0_cp_1 = num;
										stream[expr_2A0_cp_1] += 1;
									}
									num2 += 2;
									if (i % 8 != 0)
									{
										int expr_2BE_cp_1 = num;
										stream[expr_2BE_cp_1] = (byte)(stream[expr_2BE_cp_1] << 1);
									}
									else
									{
										num++;
									}
								}
							}
							else
							{
								if (mode == Mode.MR795)
								{
									short[] array = DefineConstants.order_MR795;
									int num2 = 0;
									for (i = 1; i < 160; i++)
									{
										if ((param[(int)array[num2]] & array[num2 + 1]) != 0)
										{
											int expr_307_cp_1 = num;
											stream[expr_307_cp_1] += 1;
										}
										num2 += 2;
										if (i % 8 != 0)
										{
											int expr_325_cp_1 = num;
											stream[expr_325_cp_1] = (byte)(stream[expr_325_cp_1] << 1);
										}
										else
										{
											num++;
										}
									}
								}
								else
								{
									if (mode == Mode.MR102)
									{
										short[] array = DefineConstants.order_MR102;
										int num2 = 0;
										for (i = 1; i < 205; i++)
										{
											if ((param[(int)array[num2]] & array[num2 + 1]) != 0)
											{
												int expr_36E_cp_1 = num;
												stream[expr_36E_cp_1] += 1;
											}
											num2 += 2;
											if (i % 8 != 0)
											{
												int expr_38C_cp_1 = num;
												stream[expr_38C_cp_1] = (byte)(stream[expr_38C_cp_1] << 1);
											}
											else
											{
												num++;
											}
										}
									}
									else
									{
										if (mode == Mode.MR122)
										{
											short[] array = DefineConstants.order_MR122;
											int num2 = 0;
											for (i = 1; i < 245; i++)
											{
												if ((param[(int)array[num2]] & array[num2 + 1]) != 0)
												{
													int expr_3D2_cp_1 = num;
													stream[expr_3D2_cp_1] += 1;
												}
												num2 += 2;
												if (i % 8 != 0)
												{
													int expr_3F0_cp_1 = num;
													stream[expr_3F0_cp_1] = (byte)(stream[expr_3F0_cp_1] << 1);
												}
												else
												{
													num++;
												}
											}
										}
									}
								}
							}
						}
					}
				}
			}
			int num3 = i % 8;
			if (num3 != 0)
			{
				int expr_420_cp_1 = num;
				stream[expr_420_cp_1] = (byte)(stream[expr_420_cp_1] << 8 - num3);
			}
			return (int)DefineConstants.block_size[(int)mode];
		}
		private static void Sid_Sync_reset(enc_interface_State enc_interface_State_0)
		{
			enc_interface_State_0.sid_update_counter = 3;
			enc_interface_State_0.sid_handover_debt = 0;
			enc_interface_State_0.prev_ft = TXFrameType.TX_SPEECH_GOOD;
		}
		public static object Encoder_Interface_init(int int_0)
		{
			enc_interface_State enc_interface_State = new enc_interface_State();
			enc_interface_State.encoderState = GloabFunc.Speech_Encode_Frame_init(int_0);
			GloabFunc.Sid_Sync_reset(enc_interface_State);
			enc_interface_State.int_0 = int_0;
			return enc_interface_State;
		}
		public static void Encoder_Interface_exit(object state)
		{
			enc_interface_State enc_interface_State = (enc_interface_State)state;
			GloabFunc.Speech_Encode_Frame_exit(enc_interface_State.encoderState);
		}
		public static int Encoder_Interface_Encode(object object_0, Mode mode, short[] speech, byte[] serial, int force_speech)
		{
			short[] array = new short[57];
			int num = 0;
			Mode mode2 = (Mode)(-(Mode)force_speech);
			enc_interface_State enc_interface_State = (enc_interface_State)object_0;
			for (int i = 0; i < 160; i++)
			{
				num = (int)(speech[i] ^ 8);
				if (num != 0)
				{
					break;
				}
			}
			if (num != 0)
			{
				GloabFunc.Speech_Encode_Frame(enc_interface_State.encoderState, mode, speech, 0, array, 0, ref mode2);
			}
			else
			{
				short[] array2;
				short num2;
				switch (mode)
				{
				case Mode.MR475:
					array2 = DefineConstants.dhf_MR475;
					num2 = 7;
					break;
				case Mode.MR515:
					array2 = DefineConstants.dhf_MR515;
					num2 = 7;
					break;
				case Mode.MR59:
					array2 = DefineConstants.dhf_MR59;
					num2 = 7;
					break;
				case Mode.MR67:
					array2 = DefineConstants.dhf_MR67;
					num2 = 7;
					break;
				case Mode.MR74:
					array2 = DefineConstants.dhf_MR74;
					num2 = 7;
					break;
				case Mode.MR795:
					array2 = DefineConstants.dhf_MR795;
					num2 = 8;
					break;
				case Mode.MR102:
					array2 = DefineConstants.dhf_MR102;
					num2 = 12;
					break;
				case Mode.MR122:
					array2 = DefineConstants.dhf_MR122;
					num2 = 18;
					break;
				default:
					array2 = null;
					num2 = 0;
					break;
				}
				for (int i = 0; i < (int)num2; i++)
				{
					array[i] = array2[i];
				}
				GloabFunc.memsetShort(array, (int)num2, 0, (int)(57 - num2) << 1);
				mode2 = mode;
			}
			TXFrameType tXFrameType;
			if (mode2 == Mode.MRDTX)
			{
				enc_interface_State expr_110 = enc_interface_State;
				expr_110.sid_update_counter -= 1;
				if (enc_interface_State.prev_ft == TXFrameType.TX_SPEECH_GOOD)
				{
					tXFrameType = TXFrameType.TX_SID_FIRST;
					enc_interface_State.sid_update_counter = 3;
				}
				else
				{
					if (enc_interface_State.sid_handover_debt > 0 && enc_interface_State.sid_update_counter > 2)
					{
						tXFrameType = TXFrameType.TX_SID_UPDATE;
						enc_interface_State expr_148 = enc_interface_State;
						expr_148.sid_handover_debt -= 1;
					}
					else
					{
						if (enc_interface_State.sid_update_counter == 0)
						{
							tXFrameType = TXFrameType.TX_SID_UPDATE;
							enc_interface_State.sid_update_counter = 8;
						}
						else
						{
							tXFrameType = TXFrameType.TX_NO_DATA;
							mode2 = (Mode)15;
						}
					}
				}
			}
			else
			{
				enc_interface_State.sid_update_counter = 8;
				tXFrameType = TXFrameType.TX_SPEECH_GOOD;
			}
			enc_interface_State.prev_ft = tXFrameType;
			if (num == 0)
			{
				GloabFunc.Speech_Encode_Frame_reset(enc_interface_State.encoderState, enc_interface_State.int_0);
				GloabFunc.Sid_Sync_reset(enc_interface_State);
			}
			return GloabFunc.EncoderMMS(mode2, array, serial, tXFrameType, mode);
		}
		public static int smethod_0(int int_0, int int_1)
		{
			if (int_0 >= int_1)
			{
				return int_1;
			}
			return int_0;
		}
		public static int smethod_1(int int_0, int int_1)
		{
			if (int_0 <= int_1)
			{
				return int_1;
			}
			return int_0;
		}
		public static int square(int int_0)
		{
			return int_0 * int_0;
		}
		public static void Set2D(float[,] array, int offset, float newValue)
		{
			array.GetLength(0);
			int length = array.GetLength(1);
			int num = offset / length;
			int num2 = offset % length;
			array[num, num2] = newValue;
		}
		public static float Get2D(float[,] array, int offset)
		{
			array.GetLength(0);
			int length = array.GetLength(1);
			int num = offset / length;
			int num2 = offset % length;
			return array[num, num2];
		}
		public static int GetOffset(float[,] array, int rowOffset, int colOffset)
		{
			array.GetLength(0);
			int length = array.GetLength(1);
			return length * rowOffset + colOffset;
		}
		public static float Dotproduct40(float[] float_0, int xOffset, float[] float_1, int yOffset)
		{
			float num = float_0[xOffset] * float_1[yOffset] + float_0[xOffset + 1] * float_1[yOffset + 1] + float_0[xOffset + 2] * float_1[yOffset + 2] + float_0[xOffset + 3] * float_1[yOffset + 3];
			num += float_0[xOffset + 4] * float_1[yOffset + 4] + float_0[xOffset + 5] * float_1[yOffset + 5] + float_0[xOffset + 6] * float_1[yOffset + 6] + float_0[xOffset + 7] * float_1[yOffset + 7];
			num += float_0[xOffset + 8] * float_1[yOffset + 8] + float_0[xOffset + 9] * float_1[yOffset + 9] + float_0[xOffset + 10] * float_1[yOffset + 10] + float_0[xOffset + 11] * float_1[yOffset + 11];
			num += float_0[xOffset + 12] * float_1[yOffset + 12] + float_0[xOffset + 13] * float_1[yOffset + 13] + float_0[xOffset + 14] * float_1[yOffset + 14] + float_0[xOffset + 15] * float_1[yOffset + 15];
			num += float_0[xOffset + 16] * float_1[yOffset + 16] + float_0[xOffset + 17] * float_1[yOffset + 17] + float_0[xOffset + 18] * float_1[yOffset + 18] + float_0[xOffset + 19] * float_1[yOffset + 19];
			num += float_0[xOffset + 20] * float_1[yOffset + 20] + float_0[xOffset + 21] * float_1[yOffset + 21] + float_0[xOffset + 22] * float_1[yOffset + 22] + float_0[xOffset + 23] * float_1[yOffset + 23];
			num += float_0[xOffset + 24] * float_1[yOffset + 24] + float_0[xOffset + 25] * float_1[yOffset + 25] + float_0[xOffset + 26] * float_1[yOffset + 26] + float_0[xOffset + 27] * float_1[yOffset + 27];
			num += float_0[xOffset + 28] * float_1[yOffset + 28] + float_0[xOffset + 29] * float_1[yOffset + 29] + float_0[xOffset + 30] * float_1[yOffset + 30] + float_0[xOffset + 31] * float_1[yOffset + 31];
			num += float_0[xOffset + 32] * float_1[yOffset + 32] + float_0[xOffset + 33] * float_1[yOffset + 33] + float_0[xOffset + 34] * float_1[yOffset + 34] + float_0[xOffset + 35] * float_1[yOffset + 35];
			return num + (float_0[xOffset + 36] * float_1[yOffset + 36] + float_0[xOffset + 37] * float_1[yOffset + 37] + float_0[xOffset + 38] * float_1[yOffset + 38] + float_0[xOffset + 39] * float_1[yOffset + 39]);
		}
		public static void Autocorr(float[] float_0, int xOffset, float[] float_1, int rOffSet, float[] wind, int windOffset)
		{
			float[] array = new float[251];
			for (int i = 0; i < 240; i++)
			{
				array[i] = float_0[xOffset + i] * wind[windOffset + i];
			}
			GloabFunc.memsetFloat(array, 240, 0f, 44);
			for (int i = 0; i <= 10; i++)
			{
				float num = 0f;
				for (int j = 0; j < 240; j += 40)
				{
					num += GloabFunc.Dotproduct40(array, j, array, j + i);
				}
				float_1[rOffSet + i] = num;
			}
		}
		public static void Levinson(float[] old_A, int old_AOffset, float[] float_0, int rOffset, float[] A, int AOffset, float[] float_1, int rcOffset)
		{
			float[] array = new float[10];
			array[0] = -float_0[rOffset + 1] / float_0[rOffset];
			A[AOffset] = 1f;
			A[AOffset + 1] = array[0];
			float num = float_0[rOffset] + float_0[rOffset + 1] * array[0];
			if ((double)num <= 0.0)
			{
				num = 0.01f;
			}
			for (int i = 2; i <= 10; i++)
			{
				float num2 = 0f;
				for (int j = 0; j < i; j++)
				{
					num2 += float_0[rOffset + i - j] * A[AOffset + j];
				}
				array[i - 1] = -num2 / num;
				for (int j = 1; j <= i / 2; j++)
				{
					int num3 = i - j;
					float num4 = A[AOffset + j] + array[i - 1] * A[AOffset + num3];
					A[AOffset + num3] += array[i - 1] * A[AOffset + j];
					A[AOffset + j] = num4;
				}
				A[AOffset + i] = array[i - 1];
				num += array[i - 1] * num2;
				if ((double)num <= 0.0)
				{
					num = 0.01f;
				}
			}
			GloabFunc.memcpyFloat(float_1, rcOffset, array, 0, 4);
			GloabFunc.memcpyFloat(old_A, old_AOffset, A, AOffset, 11);
		}
		public static void smethod_2(float[] old_A, int old_AOffset, float[] float_0, int xOffset, float[] x_12k2, int x_12k2Offset, float[] float_1, int aOffset, Mode mode)
		{
			float[] array = new float[11];
			float[] float_2 = new float[4];
			if (mode == Mode.MR122)
			{
				GloabFunc.Autocorr(x_12k2, x_12k2Offset, array, 0, DefineConstants.window_160_80, 0);
				for (int i = 1; i <= 10; i++)
				{
					array[i] *= DefineConstants.lag_wind[i - 1];
				}
				array[0] *= 1.0001f;
				if (array[0] < 1f)
				{
					array[0] = 1f;
				}
				GloabFunc.Levinson(old_A, old_AOffset, array, 0, float_1, aOffset + 11, float_2, 0);
				GloabFunc.Autocorr(x_12k2, x_12k2Offset, array, 0, DefineConstants.window_232_8, 0);
				for (int i = 1; i <= 10; i++)
				{
					array[i] *= DefineConstants.lag_wind[i - 1];
				}
				array[0] *= 1.0001f;
				if (array[0] < 1f)
				{
					array[0] = 1f;
				}
				GloabFunc.Levinson(old_A, old_AOffset, array, 0, float_1, aOffset + 33, float_2, 0);
				return;
			}
			GloabFunc.Autocorr(float_0, xOffset, array, 0, DefineConstants.window_200_40, 0);
			for (int i = 1; i <= 10; i++)
			{
				array[i] *= DefineConstants.lag_wind[i - 1];
			}
			array[0] *= 1.0001f;
			if (array[0] < 1f)
			{
				array[0] = 1f;
			}
			GloabFunc.Levinson(old_A, old_AOffset, array, 0, float_1, aOffset + 33, float_2, 0);
		}
		public static float Chebps(float float_0, float[] float_1, int fOffset)
		{
			float num = 2f * float_0;
			float num2 = 1f;
			float num3 = num + float_1[fOffset + 1];
			int i;
			for (i = 2; i < 5; i++)
			{
				float num4 = num * num3 - num2 + float_1[fOffset + i];
				num2 = num3;
				num3 = num4;
			}
			return float_0 * num3 - num2 + float_1[fOffset + i];
		}
		public static void Az_lsp(float[] float_0, int aOffset, float[] float_1, int lspOffset, float[] old_lsp, int old_lspOffset)
		{
			float[] array = new float[6];
			float[] array2 = new float[6];
			array[0] = 1f;
			array2[0] = 1f;
			for (int i = 0; i < 5; i++)
			{
				array[i + 1] = float_0[aOffset + i + 1] + float_0[aOffset + 10 - i] - array[i];
				array2[i + 1] = float_0[aOffset + i + 1] - float_0[aOffset + 10 - i] + array2[i];
			}
			array[5] *= 0.5f;
			array2[5] *= 0.5f;
			int num = 0;
			int num2 = 0;
			float[] float_2 = array;
			int fOffset = 0;
			float num3 = DefineConstants.grid[0];
			float num4 = GloabFunc.Chebps(num3, float_2, 0);
			int num5 = 0;
			while (num < 10 && num5 < 60)
			{
				num5++;
				float num6 = num3;
				float num7 = num4;
				num3 = DefineConstants.grid[num5];
				num4 = GloabFunc.Chebps(num3, float_2, fOffset);
				if (num4 * num7 <= 0f)
				{
					for (int i = 0; i < 4; i++)
					{
						float num8 = (num3 + num6) * 0.5f;
						float num9 = GloabFunc.Chebps(num8, float_2, fOffset);
						if (num4 * num9 <= 0f)
						{
							num7 = num9;
							num6 = num8;
						}
						else
						{
							num4 = num9;
							num3 = num8;
						}
					}
					float num10 = num7 - num4;
					float num11;
					if (num10 == 0f)
					{
						num11 = num3;
					}
					else
					{
						num10 = (num6 - num3) / (num7 - num4);
						num11 = num3 - num4 * num10;
					}
					float_1[lspOffset + num] = num11;
					num3 = num11;
					num++;
					if (num2 == 0)
					{
						num2 = 1;
						float_2 = array2;
					}
					else
					{
						num2 = 0;
						float_2 = array;
					}
					num4 = GloabFunc.Chebps(num3, float_2, fOffset);
				}
			}
			if (num < 10)
			{
				GloabFunc.memcpyFloat(float_1, lspOffset, old_lsp, old_lspOffset, 10);
			}
		}
		public static void Get_lsp_pol(float[] float_0, int lspOffset, float[] float_1, int fOffset)
		{
			float_1[fOffset] = 1f;
			float_1[fOffset + 1] = -2f * float_0[lspOffset];
			for (int i = 2; i <= 5; i++)
			{
				float num = -2f * float_0[lspOffset + 2 * i - 2];
				float_1[fOffset + i] = num * float_1[fOffset + i - 1] + 2f * float_1[fOffset + i - 2];
				for (int j = i - 1; j >= 2; j--)
				{
					float_1[fOffset + j] = float_1[fOffset + j] + num * float_1[fOffset + j - 1] + float_1[fOffset + j - 2];
				}
				float_1[fOffset + 1] = float_1[fOffset + 1] + num;
			}
		}
		private static void Lsp_Az(float[] float_0, int lspOffset, float[] float_1, int aOffSet)
		{
			float[] array = new float[6];
			float[] array2 = new float[6];
			GloabFunc.Get_lsp_pol(float_0, lspOffset, array, 0);
			GloabFunc.Get_lsp_pol(float_0, 1 + lspOffset, array2, 0);
			int i;
			for (i = 5; i > 0; i--)
			{
				array[i] += array[i - 1];
				array2[i] -= array2[i - 1];
			}
			float_1[aOffSet] = 1f;
			i = 1;
			int num = 10;
			while (i <= 5)
			{
				float_1[aOffSet + i] = (array[i] + array2[i]) * 0.5f;
				float_1[aOffSet + num] = (array[i] - array2[i]) * 0.5f;
				i++;
				num--;
			}
		}
		public static void Int_lpc_1and3_2(float[] lsp_old, int lsp_oldOffset, float[] lsp_mid, int lsp_midOffset, float[] lsp_new, int lsp_newOffset, float[] float_0, int azOffset)
		{
			float[] array = new float[10];
			for (int i = 0; i < 10; i += 2)
			{
				array[i] = (lsp_mid[lsp_midOffset + i] + lsp_old[lsp_oldOffset + i]) * 0.5f;
				array[i + 1] = (lsp_mid[lsp_midOffset + i + 1] + lsp_old[lsp_oldOffset + i + 1]) * 0.5f;
			}
			GloabFunc.Lsp_Az(array, 0, float_0, azOffset);
			azOffset += 22;
			for (int i = 0; i < 10; i += 2)
			{
				array[i] = (lsp_mid[lsp_midOffset + i] + lsp_new[lsp_newOffset + i]) * 0.5f;
				array[i + 1] = (lsp_mid[lsp_midOffset + i + 1] + lsp_new[lsp_newOffset + i + 1]) * 0.5f;
			}
			GloabFunc.Lsp_Az(array, 0, float_0, azOffset);
		}
		public static void Lsp_lsf(float[] float_0, int lspOffset, float[] float_1, int lsfOffset)
		{
			for (int i = 0; i < 10; i++)
			{
				float_1[lsfOffset + i] = (float)(Math.Acos((double)float_0[lspOffset + i]) * 1273.239501953125);
			}
		}
		public static void Lsf_wt(float[] float_0, int lsfOffset, float[] float_1, int wfOffset)
		{
			float_1[wfOffset] = float_0[lsfOffset + 1];
			for (int i = 1; i < 9; i++)
			{
				float_1[wfOffset + i] = float_0[lsfOffset + i + 1] - float_0[lsfOffset + i - 1];
			}
			float_1[wfOffset + 9] = 4000f - float_0[lsfOffset + 8];
			for (int i = 0; i < 10; i++)
			{
				float num;
				if (float_1[wfOffset + i] < 450f)
				{
					num = 3.347f - 0.00343777775f * float_1[wfOffset + i];
				}
				else
				{
					num = 1.8f - 0.000761904754f * (float_1[wfOffset + i] - 450f);
				}
				float_1[wfOffset + i] = num * num;
			}
		}
		public static short Vq_subvec(float[] lsf_r1, int lsf_r1Offset, float[] lsf_r2, int lsf_r2Offset, float[] dico, int dicoOffset, float[] float_0, int wf1Offset, float[] float_1, int wf2Offset, short dico_size)
		{
			int num = 0;
			float num2 = float.PositiveInfinity;
			int num3 = dicoOffset;
			for (int i = 0; i < (int)dico_size; i++)
			{
				float num4 = lsf_r1[lsf_r1Offset] - dico[num3++];
				float num5 = num4 * num4 * float_0[wf1Offset];
				num4 = lsf_r1[lsf_r1Offset + 1] - dico[num3++];
				num5 += num4 * num4 * float_0[wf1Offset + 1];
				num4 = lsf_r2[lsf_r2Offset] - dico[num3++];
				num5 += num4 * num4 * float_1[wf2Offset];
				num4 = lsf_r2[lsf_r2Offset + 1] - dico[num3++];
				num5 += num4 * num4 * float_1[wf2Offset + 1];
				if (num5 < num2)
				{
					num2 = num5;
					num = i;
				}
			}
			num3 = dicoOffset + num << 2;
			lsf_r1[lsf_r1Offset] = dico[num3++];
			lsf_r1[lsf_r1Offset + 1] = dico[num3++];
			lsf_r2[lsf_r2Offset] = dico[num3++];
			lsf_r2[lsf_r2Offset + 1] = dico[num3++];
			return (short)num;
		}
		private static short Vq_subvec_s(float[] lsf_r1, int lsf_r1Offset, float[] lsf_r2, int lsf_r2Offset, float[] dico, int dicoOffset, float[] float_0, int wf1Offset, float[] float_1, int wf2Offset, short dico_size)
		{
			int num = 0;
			short num2 = 0;
			float num3 = float.PositiveInfinity;
			int num4 = dicoOffset;
			for (int i = 0; i < (int)dico_size; i++)
			{
				float num5 = lsf_r1[lsf_r1Offset] - dico[num4];
				float num6 = lsf_r1[lsf_r1Offset] + dico[num4++];
				float num7 = num5 * num5 * float_0[wf1Offset];
				float num8 = num6 * num6 * float_0[wf1Offset];
				num5 = lsf_r1[lsf_r1Offset + 1] - dico[num4];
				num6 = lsf_r1[lsf_r1Offset + 1] + dico[num4++];
				num7 += num5 * num5 * float_0[wf1Offset + 1];
				num8 += num6 * num6 * float_0[wf1Offset + 1];
				num5 = lsf_r2[lsf_r2Offset] - dico[num4];
				num6 = lsf_r2[lsf_r2Offset] + dico[num4++];
				num7 += num5 * num5 * float_1[wf2Offset];
				num8 += num6 * num6 * float_1[wf2Offset];
				num5 = lsf_r2[lsf_r2Offset + 1] - dico[num4];
				num6 = lsf_r2[lsf_r2Offset + 1] + dico[num4++];
				num7 += num5 * num5 * float_1[wf2Offset + 1];
				num8 += num6 * num6 * float_1[wf2Offset + 1];
				if (num7 < num3)
				{
					num3 = num7;
					num = i;
					num2 = 0;
				}
				if (num8 < num3)
				{
					num3 = num8;
					num = i;
					num2 = 1;
				}
			}
			num4 = dicoOffset + num << 2;
			if (num2 == 0)
			{
				lsf_r1[lsf_r1Offset] = dico[num4++];
				lsf_r1[lsf_r1Offset + 1] = dico[num4++];
				lsf_r2[lsf_r2Offset] = dico[num4++];
				lsf_r2[lsf_r2Offset + 1] = dico[num4++];
			}
			else
			{
				lsf_r1[lsf_r1Offset] = -dico[num4++];
				lsf_r1[lsf_r1Offset + 1] = -dico[num4++];
				lsf_r2[lsf_r2Offset] = -dico[num4++];
				lsf_r2[lsf_r2Offset + 1] = -dico[num4++];
			}
			num <<= 1;
			num += (int)num2;
			return (short)num;
		}
		private static void Reorder_lsf(float[] float_0, int lsfOffset, float min_dist)
		{
			float num = min_dist;
			for (int i = 0; i < 10; i++)
			{
				if (float_0[lsfOffset + i] < num)
				{
					float_0[lsfOffset + i] = num;
				}
				num = float_0[lsfOffset + i] + min_dist;
			}
		}
		private static void Lsf_lsp(float[] float_0, int lsfOffset, float[] float_1, int lspOffset)
		{
			for (int i = 0; i < 10; i++)
			{
				float_1[lspOffset + i] = (float)Math.Cos((double)(0.0007853982f * float_0[lsfOffset + i]));
			}
		}
		private static short Vq_subvec3(float[] lsf_r1, int lsf_r1Offset, float[] dico, int dicoOffset, float[] float_0, int wf1Offset, short dico_size, int use_half)
		{
			int num = 0;
			double num2 = 3.4028234663852886E+38;
			int num3 = dicoOffset;
			float[] array;
			if (use_half == 0)
			{
				for (int i = 0; i < (int)dico_size; i++)
				{
					float num4 = lsf_r1[lsf_r1Offset] - dico[num3++];
					num4 *= float_0[wf1Offset];
					double num5 = (double)(num4 * num4);
					num4 = lsf_r1[lsf_r1Offset + 1] - dico[num3++];
					num4 *= float_0[wf1Offset + 1];
					num5 += (double)(num4 * num4);
					num4 = lsf_r1[lsf_r1Offset + 2] - dico[num3++];
					num4 *= float_0[wf1Offset + 2];
					num5 += (double)(num4 * num4);
					if (num5 < num2)
					{
						num2 = num5;
						num = i;
					}
				}
				array = dico;
				num3 = 3 * num + dicoOffset;
			}
			else
			{
				for (int i = 0; i < (int)dico_size; i++)
				{
					float num4 = lsf_r1[lsf_r1Offset] - dico[num3++];
					num4 *= float_0[wf1Offset];
					double num5 = (double)(num4 * num4);
					num4 = lsf_r1[lsf_r1Offset + 1] - dico[num3++];
					num4 *= float_0[wf1Offset + 1];
					num5 += (double)(num4 * num4);
					num4 = lsf_r1[lsf_r1Offset + 2] - dico[num3++];
					num4 *= float_0[wf1Offset + 2];
					num5 += (double)(num4 * num4);
					if (num5 < num2)
					{
						num2 = num5;
						num = i;
					}
					num3 += 3;
				}
				array = dico;
				num3 = 6 * num + dicoOffset;
			}
			lsf_r1[lsf_r1Offset] = array[num3++];
			lsf_r1[lsf_r1Offset + 1] = array[num3++];
			lsf_r1[lsf_r1Offset + 2] = array[num3++];
			return (short)num;
		}
		private static short Vq_subvec4(float[] lsf_r1, int lsf_r1Offset, float[] dico, int dicoOffset, float[] float_0, int wf1Offset, short dico_size)
		{
			int num = 0;
			double num2 = 3.4028234663852886E+38;
			int num3 = dicoOffset;
			for (int i = 0; i < (int)dico_size; i++)
			{
				float num4 = lsf_r1[lsf_r1Offset] - dico[num3++];
				num4 *= float_0[wf1Offset];
				double num5 = (double)(num4 * num4);
				num4 = lsf_r1[lsf_r1Offset + 1] - dico[num3++];
				num4 *= float_0[wf1Offset + 1];
				num5 += (double)(num4 * num4);
				num4 = lsf_r1[lsf_r1Offset + 2] - dico[num3++];
				num4 *= float_0[wf1Offset + 2];
				num5 += (double)(num4 * num4);
				num4 = lsf_r1[lsf_r1Offset + 3] - dico[num3++];
				num4 *= float_0[wf1Offset + 3];
				num5 += (double)(num4 * num4);
				if (num5 < num2)
				{
					num2 = num5;
					num = i;
				}
			}
			num3 = dicoOffset + num << 2;
			lsf_r1[lsf_r1Offset] = dico[num3++];
			lsf_r1[lsf_r1Offset + 1] = dico[num3++];
			lsf_r1[lsf_r1Offset + 2] = dico[num3++];
			lsf_r1[lsf_r1Offset + 3] = dico[num3++];
			return (short)num;
		}
		private static void Q_plsf_3(Mode mode, float[] past_rq, int past_rqOffset, float[] lsp1, int lsp1Offset, float[] lsp1_q, int lsp1_qOffset, short[] indice, int indiceOffset, ref int pred_init_i)
		{
			float[] array = new float[10];
			float[] array2 = new float[10];
			float[] array3 = new float[10];
			float[] array4 = new float[10];
			float[] array5 = new float[10];
			float[] array6 = new float[10];
			float[] array7 = new float[10];
			GloabFunc.Lsp_lsf(lsp1, lsp1Offset, array, 0);
			GloabFunc.Lsf_wt(array, 0, array2, 0);
			if (mode != Mode.MRDTX)
			{
				for (int i = 0; i < 10; i++)
				{
					array3[i] = DefineConstants.mean_lsf_3[i] + past_rq[past_rqOffset + i] * DefineConstants.pred_fac[i];
					array4[i] = array[i] - array3[i];
				}
			}
			else
			{
				pred_init_i = 0;
				float num = 3.40282347E+38f;
				for (int j = 0; j < 8; j++)
				{
					float num2 = 0f;
					for (int i = 0; i < 10; i++)
					{
						array7[i] = DefineConstants.mean_lsf_3[i] + DefineConstants.past_rq_init[j * 10 + i];
						array6[i] = array[i] - array7[i];
						num2 += array6[i] * array6[i];
					}
					if (num2 < num)
					{
						num = num2;
						GloabFunc.memcpyFloat(array4, 0, array6, 0, 10);
						GloabFunc.memcpyFloat(array3, 0, array7, 0, 10);
						GloabFunc.memcpyFloat(past_rq, past_rqOffset, DefineConstants.past_rq_init, j * 10, 10);
						pred_init_i = j;
					}
				}
			}
			if (mode != Mode.MR475)
			{
				if (mode != Mode.MR515)
				{
					if (mode == Mode.MR795)
					{
						indice[indiceOffset] = GloabFunc.Vq_subvec3(array4, 0, DefineConstants.mr795_1_lsf, 0, array2, 0, 512, 0);
						indice[indiceOffset + 1] = GloabFunc.Vq_subvec3(array4, 3, DefineConstants.dico2_lsf_3, 0, array2, 3, 512, 0);
						indice[indiceOffset + 2] = GloabFunc.Vq_subvec4(array4, 6, DefineConstants.dico3_lsf_3, 0, array2, 6, 512);
						goto IL_24C;
					}
					indice[indiceOffset] = GloabFunc.Vq_subvec3(array4, 0, DefineConstants.dico1_lsf_3, 0, array2, 0, 256, 0);
					indice[indiceOffset + 1] = GloabFunc.Vq_subvec3(array4, 3, DefineConstants.dico2_lsf_3, 0, array2, 3, 512, 0);
					indice[indiceOffset + 2] = GloabFunc.Vq_subvec4(array4, 6, DefineConstants.dico3_lsf_3, 0, array2, 6, 512);
					goto IL_24C;
				}
			}
			indice[indiceOffset] = GloabFunc.Vq_subvec3(array4, 0, DefineConstants.dico1_lsf_3, 0, array2, 0, 256, 0);
			indice[indiceOffset + 1] = GloabFunc.Vq_subvec3(array4, 3, DefineConstants.dico2_lsf_3, 0, array2, 3, 256, 1);
			indice[indiceOffset + 2] = GloabFunc.Vq_subvec4(array4, 6, DefineConstants.mr515_3_lsf, 0, array2, 6, 128);
			IL_24C:
			for (int i = 0; i < 10; i++)
			{
				array5[i] = array4[i] + array3[i];
				past_rq[past_rqOffset + i] = array4[i];
			}
			GloabFunc.Reorder_lsf(array5, 0, 50f);
			GloabFunc.Lsf_lsp(array5, 0, lsp1_q, lsp1_qOffset);
		}
		private static void Q_plsf_5(float[] past_rq, int past_rqOffset, float[] lsp1, int lsp1Offset, float[] lsp2, int lsp2Offset, float[] lsp1_q, int lsp1_qOffset, float[] lsp2_q, int lsp2_qOffset, short[] indice, int indiceOffset)
		{
			float[] array = new float[10];
			float[] array2 = new float[10];
			float[] array3 = new float[10];
			float[] float_ = new float[10];
			float[] array4 = new float[10];
			float[] array5 = new float[10];
			float[] array6 = new float[10];
			float[] array7 = new float[10];
			float[] array8 = new float[10];
			GloabFunc.Lsp_lsf(lsp1, lsp1Offset, array, 0);
			GloabFunc.Lsp_lsf(lsp2, lsp2Offset, array2, 0);
			GloabFunc.Lsf_wt(array, 0, array3, 0);
			GloabFunc.Lsf_wt(array2, 0, float_, 0);
			for (int i = 0; i < 10; i++)
			{
				array4[i] = DefineConstants.mean_lsf_5[i] + past_rq[past_rqOffset + i] * 0.65f;
				array5[i] = array[i] - array4[i];
				array6[i] = array2[i] - array4[i];
			}
			indice[indiceOffset] = GloabFunc.Vq_subvec(array5, 0, array6, 0, DefineConstants.dico1_lsf_5, 0, array3, 0, float_, 0, 128);
			indice[indiceOffset + 1] = GloabFunc.Vq_subvec(array5, 2, array6, 2, DefineConstants.dico2_lsf_5, 0, array3, 2, float_, 2, 256);
			indice[indiceOffset + 2] = GloabFunc.Vq_subvec_s(array5, 4, array6, 4, DefineConstants.dico3_lsf_5, 0, array3, 4, float_, 4, 256);
			indice[indiceOffset + 3] = GloabFunc.Vq_subvec(array5, 6, array6, 6, DefineConstants.dico4_lsf_5, 0, array3, 6, float_, 6, 256);
			indice[indiceOffset + 4] = GloabFunc.Vq_subvec(array5, 8, array6, 8, DefineConstants.dico5_lsf_5, 0, array3, 8, float_, 8, 64);
			for (int i = 0; i < 10; i++)
			{
				array7[i] = array5[i] + array4[i];
				array8[i] = array6[i] + array4[i];
				past_rq[past_rqOffset + i] = array6[i];
			}
			GloabFunc.Reorder_lsf(array7, 0, 50f);
			GloabFunc.Reorder_lsf(array8, 0, 50f);
			GloabFunc.Lsf_lsp(array7, 0, lsp1_q, lsp1_qOffset);
			GloabFunc.Lsf_lsp(array8, 0, lsp2_q, lsp2_qOffset);
		}
		private static void Int_lpc_1and3(float[] lsp_old, int lsp_oldOffset, float[] lsp_mid, int lsp_midOffset, float[] lsp_new, int lsp_newOffset, float[] float_0, int azOffset)
		{
			float[] array = new float[10];
			for (int i = 0; i < 10; i++)
			{
				array[i] = (lsp_mid[lsp_midOffset + i] + lsp_old[lsp_oldOffset + i]) * 0.5f;
			}
			GloabFunc.Lsp_Az(array, 0, float_0, azOffset);
			azOffset += 11;
			GloabFunc.Lsp_Az(lsp_mid, lsp_midOffset, float_0, azOffset);
			azOffset += 11;
			for (int i = 0; i < 10; i++)
			{
				array[i] = (lsp_mid[lsp_midOffset + i] + lsp_new[lsp_newOffset + i]) * 0.5f;
			}
			GloabFunc.Lsp_Az(array, 0, float_0, azOffset);
			azOffset += 11;
			GloabFunc.Lsp_Az(lsp_new, lsp_newOffset, float_0, azOffset);
		}
		private static void Int_lpc_1to3_2(float[] lsp_old, int lsp_oldOffset, float[] lsp_new, int lsp_newOffset, float[] float_0, int azOffset)
		{
			float[] array = new float[10];
			for (int i = 0; i < 10; i += 2)
			{
				array[i] = lsp_new[lsp_newOffset + i] * 0.25f + lsp_old[lsp_oldOffset + i] * 0.75f;
				array[i + 1] = lsp_new[lsp_newOffset + i + 1] * 0.25f + lsp_old[lsp_oldOffset + i + 1] * 0.75f;
			}
			GloabFunc.Lsp_Az(array, 0, float_0, azOffset);
			azOffset += 11;
			for (int i = 0; i < 10; i += 2)
			{
				array[i] = (lsp_old[lsp_oldOffset + i] + lsp_new[lsp_newOffset + i]) * 0.5f;
				array[i + 1] = (lsp_old[lsp_oldOffset + i + 1] + lsp_new[lsp_newOffset + i + 1]) * 0.5f;
			}
			GloabFunc.Lsp_Az(array, 0, float_0, azOffset);
			azOffset += 11;
			for (int i = 0; i < 10; i += 2)
			{
				array[i] = lsp_old[lsp_oldOffset + i] * 0.25f + lsp_new[lsp_newOffset + i] * 0.75f;
				array[i + 1] = lsp_old[lsp_oldOffset + i + 1] * 0.25f + lsp_new[lsp_newOffset + i + 1] * 0.75f;
			}
			GloabFunc.Lsp_Az(array, 0, float_0, azOffset);
		}
		private static void Int_lpc_1to3(float[] lsp_old, int lsp_oldOffset, float[] lsp_new, int lsp_newOffset, float[] float_0, int azOffset)
		{
			float[] array = new float[10];
			for (int i = 0; i < 10; i++)
			{
				array[i] = lsp_new[lsp_newOffset + i] * 0.25f + lsp_old[lsp_oldOffset + i] * 0.75f;
			}
			GloabFunc.Lsp_Az(array, 0, float_0, azOffset);
			azOffset += 11;
			for (int i = 0; i < 10; i++)
			{
				array[i] = (lsp_old[lsp_oldOffset + i] + lsp_new[lsp_newOffset + i]) * 0.5f;
			}
			GloabFunc.Lsp_Az(array, 0, float_0, azOffset);
			azOffset += 11;
			for (int i = 0; i < 10; i++)
			{
				array[i] = lsp_old[lsp_oldOffset + i] * 0.25f + lsp_new[lsp_newOffset + i] * 0.75f;
			}
			GloabFunc.Lsp_Az(array, 0, float_0, azOffset);
			azOffset += 11;
			GloabFunc.Lsp_Az(lsp_new, lsp_newOffset, float_0, azOffset);
		}
		private static void smethod_3(Mode req_mode, Mode used_mode, float[] lsp_old, int lsp_oldOffset, float[] lsp_old_q, int lsp_old_qOffset, float[] past_rq, int past_rqOffset, float[] float_0, int azOffset, float[] azQ, int azQOffset, float[] lsp_new, int lsp_newOffset, short[] anap, ref short anapOffset)
		{
			float[] array = new float[10];
			float[] array2 = new float[10];
			float[] array3 = new float[10];
			int num = 0;
			if (req_mode == Mode.MR122)
			{
				GloabFunc.Az_lsp(float_0, azOffset + 11, array2, 0, lsp_old, lsp_oldOffset);
				GloabFunc.Az_lsp(float_0, azOffset + 33, lsp_new, lsp_newOffset, array2, 0);
				GloabFunc.Int_lpc_1and3_2(lsp_old, lsp_oldOffset, array2, 0, lsp_new, lsp_newOffset, float_0, azOffset);
				if (used_mode != Mode.MRDTX)
				{
					GloabFunc.Q_plsf_5(past_rq, past_rqOffset, array2, 0, lsp_new, lsp_newOffset, array3, 0, array, 0, anap, (int)anapOffset);
					GloabFunc.Int_lpc_1and3(lsp_old_q, lsp_old_qOffset, array3, 0, array, 0, azQ, azQOffset);
					azQOffset += 5;
				}
			}
			else
			{
				GloabFunc.Az_lsp(float_0, azOffset + 33, lsp_new, lsp_newOffset, lsp_old, lsp_oldOffset);
				GloabFunc.Int_lpc_1to3_2(lsp_old, lsp_oldOffset, lsp_new, lsp_newOffset, float_0, azOffset);
				if (used_mode != Mode.MRDTX)
				{
					GloabFunc.Q_plsf_3(req_mode, past_rq, past_rqOffset, lsp_new, lsp_newOffset, array, 0, anap, (int)anapOffset, ref num);
					GloabFunc.Int_lpc_1to3(lsp_old_q, lsp_old_qOffset, array, 0, azQ, azQOffset);
					anapOffset += 3;
				}
			}
			GloabFunc.memcpyFloat(lsp_old, lsp_oldOffset, lsp_new, lsp_newOffset, 10);
			GloabFunc.memcpyFloat(lsp_old_q, lsp_old_qOffset, array, 0, 10);
		}
		private static short check_lsp(ref short count, float[] float_0, int lspOffset)
		{
			float num = 3.40282347E+38f;
			for (int i = 3; i < 8; i++)
			{
				float num2 = float_0[lspOffset + i] - float_0[lspOffset + i + 1];
				if (num2 < num)
				{
					num = num2;
				}
			}
			float num3 = 3.40282347E+38f;
			for (int i = 1; i < 3; i++)
			{
				float num2 = float_0[lspOffset + i] - float_0[lspOffset + i + 1];
				if (num2 < num3)
				{
					num3 = num2;
				}
			}
			float num4;
			if (float_0[lspOffset + 1] > 0.98f)
			{
				num4 = 0.018f;
			}
			else
			{
				if (float_0[lspOffset + 1] > 0.93f)
				{
					num4 = 0.024f;
				}
				else
				{
					num4 = 0.034f;
				}
			}
			if (num >= 0.046f && num3 >= num4)
			{
				count = 0;
			}
			else
			{
				count += 1;
			}
			if (count >= 12)
			{
				count = 12;
				return 1;
			}
			return 0;
		}
		private static void Weight_Ai(float[] float_0, int aOffset, float[] float_1, int facOffset, float[] a_exp, int a_expOffset)
		{
			a_exp[a_expOffset] = float_0[aOffset];
			for (int i = 1; i <= 10; i++)
			{
				a_exp[a_expOffset + i] = float_0[aOffset + i] * float_1[facOffset + i - 1];
			}
		}
		private static void Residu(float[] float_0, int aOffset, float[] float_1, int xOffset, float[] float_2, int yOffset)
		{
			for (int i = 0; i < 40; i += 4)
			{
				float num = float_1[xOffset + i] * float_0[aOffset];
				num += float_1[xOffset + i - 1] * float_0[aOffset + 1];
				num += float_1[xOffset + i - 2] * float_0[aOffset + 2];
				num += float_1[xOffset + i - 3] * float_0[aOffset + 3];
				num += float_1[xOffset + i - 4] * float_0[aOffset + 4];
				num += float_1[xOffset + i - 5] * float_0[aOffset + 5];
				num += float_1[xOffset + i - 6] * float_0[aOffset + 6];
				num += float_1[xOffset + i - 7] * float_0[aOffset + 7];
				num += float_1[xOffset + i - 8] * float_0[aOffset + 8];
				num += float_1[xOffset + i - 9] * float_0[aOffset + 9];
				num += float_1[xOffset + i - 10] * float_0[aOffset + 10];
				float_2[yOffset + i] = num;
				num = float_1[xOffset + i + 1] * float_0[aOffset];
				num += float_1[xOffset + i] * float_0[aOffset + 1];
				num += float_1[xOffset + i - 1] * float_0[aOffset + 2];
				num += float_1[xOffset + i - 2] * float_0[aOffset + 3];
				num += float_1[xOffset + i - 3] * float_0[aOffset + 4];
				num += float_1[xOffset + i - 4] * float_0[aOffset + 5];
				num += float_1[xOffset + i - 5] * float_0[aOffset + 6];
				num += float_1[xOffset + i - 6] * float_0[aOffset + 7];
				num += float_1[xOffset + i - 7] * float_0[aOffset + 8];
				num += float_1[xOffset + i - 8] * float_0[aOffset + 9];
				num += float_1[xOffset + i - 9] * float_0[aOffset + 10];
				float_2[yOffset + i + 1] = num;
				num = float_1[xOffset + i + 2] * float_0[aOffset];
				num += float_1[xOffset + i + 1] * float_0[aOffset + 1];
				num += float_1[xOffset + i] * float_0[aOffset + 2];
				num += float_1[xOffset + i - 1] * float_0[aOffset + 3];
				num += float_1[xOffset + i - 2] * float_0[aOffset + 4];
				num += float_1[xOffset + i - 3] * float_0[aOffset + 5];
				num += float_1[xOffset + i - 4] * float_0[aOffset + 6];
				num += float_1[xOffset + i - 5] * float_0[aOffset + 7];
				num += float_1[xOffset + i - 6] * float_0[aOffset + 8];
				num += float_1[xOffset + i - 7] * float_0[aOffset + 9];
				num += float_1[xOffset + i - 8] * float_0[aOffset + 10];
				float_2[yOffset + i + 2] = num;
				num = float_1[xOffset + i + 3] * float_0[aOffset];
				num += float_1[xOffset + i + 2] * float_0[aOffset + 1];
				num += float_1[xOffset + i + 1] * float_0[aOffset + 2];
				num += float_1[xOffset + i] * float_0[aOffset + 3];
				num += float_1[xOffset + i - 1] * float_0[aOffset + 4];
				num += float_1[xOffset + i - 2] * float_0[aOffset + 5];
				num += float_1[xOffset + i - 3] * float_0[aOffset + 6];
				num += float_1[xOffset + i - 4] * float_0[aOffset + 7];
				num += float_1[xOffset + i - 5] * float_0[aOffset + 8];
				num += float_1[xOffset + i - 6] * float_0[aOffset + 9];
				num += float_1[xOffset + i - 7] * float_0[aOffset + 10];
				float_2[yOffset + i + 3] = num;
			}
		}
		private static void Syn_filt(float[] float_0, int aOffset, float[] float_1, int xOffset, float[] float_2, int yOffset, float[] float_3, int memOffset, short update)
		{
			float[] array = new float[50];
			int num = 0;
			float[] array2 = array;
			for (int i = 0; i < 10; i++)
			{
				array2[num++] = float_3[memOffset + i];
			}
			for (int i = 0; i < 40; i += 4)
			{
				double num2 = (double)(float_1[xOffset + i] * float_0[aOffset]);
				num2 -= (double)(float_0[aOffset + 1] * array2[num - 1]);
				num2 -= (double)(float_0[aOffset + 2] * array2[num - 2]);
				num2 -= (double)(float_0[aOffset + 3] * array2[num - 3]);
				num2 -= (double)(float_0[aOffset + 4] * array2[num - 4]);
				num2 -= (double)(float_0[aOffset + 5] * array2[num - 5]);
				num2 -= (double)(float_0[aOffset + 6] * array2[num - 6]);
				num2 -= (double)(float_0[aOffset + 7] * array2[num - 7]);
				num2 -= (double)(float_0[aOffset + 8] * array2[num - 8]);
				num2 -= (double)(float_0[aOffset + 9] * array2[num - 9]);
				num2 -= (double)(float_0[aOffset + 10] * array2[num - 10]);
				array2[num++] = (float)num2;
				float_2[yOffset + i] = array2[num - 1];
				num2 = (double)(float_1[xOffset + i + 1] * float_0[aOffset]);
				num2 -= (double)(float_0[aOffset + 1] * array2[num - 1]);
				num2 -= (double)(float_0[aOffset + 2] * array2[num - 2]);
				num2 -= (double)(float_0[aOffset + 3] * array2[num - 3]);
				num2 -= (double)(float_0[aOffset + 4] * array2[num - 4]);
				num2 -= (double)(float_0[aOffset + 5] * array2[num - 5]);
				num2 -= (double)(float_0[aOffset + 6] * array2[num - 6]);
				num2 -= (double)(float_0[aOffset + 7] * array2[num - 7]);
				num2 -= (double)(float_0[aOffset + 8] * array2[num - 8]);
				num2 -= (double)(float_0[aOffset + 9] * array2[num - 9]);
				num2 -= (double)(float_0[aOffset + 10] * array2[num - 10]);
				array2[num++] = (float)num2;
				float_2[yOffset + i + 1] = array2[num - 1];
				num2 = (double)(float_1[xOffset + i + 2] * float_0[aOffset]);
				num2 -= (double)(float_0[aOffset + 1] * array2[num - 1]);
				num2 -= (double)(float_0[aOffset + 2] * array2[num - 2]);
				num2 -= (double)(float_0[aOffset + 3] * array2[num - 3]);
				num2 -= (double)(float_0[aOffset + 4] * array2[num - 4]);
				num2 -= (double)(float_0[aOffset + 5] * array2[num - 5]);
				num2 -= (double)(float_0[aOffset + 6] * array2[num - 6]);
				num2 -= (double)(float_0[aOffset + 7] * array2[num - 7]);
				num2 -= (double)(float_0[aOffset + 8] * array2[num - 8]);
				num2 -= (double)(float_0[aOffset + 9] * array2[num - 9]);
				num2 -= (double)(float_0[aOffset + 10] * array2[num - 10]);
				array2[num++] = (float)num2;
				float_2[yOffset + i + 2] = array2[num - 1];
				num2 = (double)(float_1[xOffset + i + 3] * float_0[aOffset]);
				num2 -= (double)(float_0[aOffset + 1] * array2[num - 1]);
				num2 -= (double)(float_0[aOffset + 2] * array2[num - 2]);
				num2 -= (double)(float_0[aOffset + 3] * array2[num - 3]);
				num2 -= (double)(float_0[aOffset + 4] * array2[num - 4]);
				num2 -= (double)(float_0[aOffset + 5] * array2[num - 5]);
				num2 -= (double)(float_0[aOffset + 6] * array2[num - 6]);
				num2 -= (double)(float_0[aOffset + 7] * array2[num - 7]);
				num2 -= (double)(float_0[aOffset + 8] * array2[num - 8]);
				num2 -= (double)(float_0[aOffset + 9] * array2[num - 9]);
				num2 -= (double)(float_0[aOffset + 10] * array2[num - 10]);
				array2[num++] = (float)num2;
				float_2[yOffset + i + 3] = array2[num - 1];
			}
			if (update != 0)
			{
				for (int i = 0; i < 10; i++)
				{
					float_3[memOffset + i] = float_2[yOffset + 30 + i];
				}
			}
		}
		private static int pre_big(Mode mode, float[] gamma1, int gamma1Offset, float[] gamma1_12k2, int gamma1_12k2Offset, float[] gamma2, int gamma2Offset, float[] A_t, int A_tOffset, short frame_offset, float[] speech, int speechOffset, float[] mem_w, int mem_wOffset, float[] float_0, int wspOffset)
		{
			float[] array = new float[11];
			float[] array2 = new float[11];
			float[] float_ = gamma1_12k2;
			int facOffset = gamma1_12k2Offset;
			if (mode <= Mode.MR795)
			{
				float_ = gamma1;
				facOffset = gamma1Offset;
			}
			int num = 0;
			if (frame_offset > 0)
			{
				num = 22;
			}
			for (int i = 0; i < 2; i++)
			{
				GloabFunc.Weight_Ai(A_t, A_tOffset + num, float_, facOffset, array, 0);
				GloabFunc.Weight_Ai(A_t, A_tOffset + num, gamma2, gamma2Offset, array2, 0);
				GloabFunc.Residu(array, 0, speech, speechOffset + (int)frame_offset, float_0, wspOffset + (int)frame_offset);
				GloabFunc.Syn_filt(array2, 0, float_0, wspOffset + (int)frame_offset, float_0, wspOffset + (int)frame_offset, mem_w, mem_wOffset, 1);
				num += 11;
				frame_offset += 40;
			}
			return 0;
		}
		private static void comp_corr(float[] float_0, int sigOffset, int L_frame, int lag_max, int lag_min, float[] corr, int corrOffset)
		{
			for (int i = lag_max; i >= lag_min; i--)
			{
				int num = sigOffset;
				int num2 = sigOffset - i;
				float num3 = 0f;
				int j = 0;
				while (j < L_frame)
				{
					num3 += float_0[num] * float_0[num2] + float_0[num + 1] * float_0[num2 + 1] + float_0[num + 2] * float_0[num2 + 2] + float_0[num + 3] * float_0[num2 + 3];
					num3 += float_0[num + 4] * float_0[num2 + 4] + float_0[num + 5] * float_0[num2 + 5] + float_0[num + 6] * float_0[num2 + 6] + float_0[num + 7] * float_0[num2 + 7];
					num3 += float_0[num + 8] * float_0[num2 + 8] + float_0[num + 9] * float_0[num2 + 9] + float_0[num + 10] * float_0[num2 + 10] + float_0[num + 11] * float_0[num2 + 11];
					num3 += float_0[num + 12] * float_0[num2 + 12] + float_0[num + 13] * float_0[num2 + 13] + float_0[num + 14] * float_0[num2 + 14] + float_0[num + 15] * float_0[num2 + 15];
					num3 += float_0[num + 16] * float_0[num2 + 16] + float_0[num + 17] * float_0[num2 + 17] + float_0[num + 18] * float_0[num2 + 18] + float_0[num + 19] * float_0[num2 + 19];
					num3 += float_0[num + 20] * float_0[num2 + 20] + float_0[num + 21] * float_0[num2 + 21] + float_0[num + 22] * float_0[num2 + 22] + float_0[num + 23] * float_0[num2 + 23];
					num3 += float_0[num + 24] * float_0[num2 + 24] + float_0[num + 25] * float_0[num2 + 25] + float_0[num + 26] * float_0[num2 + 26] + float_0[num + 27] * float_0[num2 + 27];
					num3 += float_0[num + 28] * float_0[num2 + 28] + float_0[num + 29] * float_0[num2 + 29] + float_0[num + 30] * float_0[num2 + 30] + float_0[num + 31] * float_0[num2 + 31];
					num3 += float_0[num + 32] * float_0[num2 + 32] + float_0[num + 33] * float_0[num2 + 33] + float_0[num + 34] * float_0[num2 + 34] + float_0[num + 35] * float_0[num2 + 35];
					num3 += float_0[num + 36] * float_0[num2 + 36] + float_0[num + 37] * float_0[num2 + 37] + float_0[num + 38] * float_0[num2 + 38] + float_0[num + 39] * float_0[num2 + 39];
					j += 40;
					num += 40;
					num2 += 40;
				}
				corr[corrOffset - i] = num3;
			}
		}
		private static short Lag_max(float[] corr, int corrOffset, float[] float_0, int sigOffset, short L_frame, int lag_max, int lag_min, ref float cor_max, int int_0, ref float rmax, ref float float_1)
		{
			float num = -3.40282347E+38f;
			int num2 = lag_max;
			int i = lag_max;
			int num3 = 143 - lag_max - 1;
			while (i >= lag_min)
			{
				if (corr[corrOffset - i] >= num)
				{
					num = corr[corrOffset - i];
					num2 = i;
				}
				i--;
				num3--;
			}
			float num4 = 0f;
			int num5 = sigOffset - num2;
			i = 0;
			while (i < (int)L_frame)
			{
				num4 += float_0[num5] * float_0[num5];
				i++;
				num5++;
			}
			if (int_0 != 0)
			{
				rmax = num;
				float_1 = num4;
			}
			if (num4 > 0f)
			{
				num4 = 1f / (float)Math.Sqrt((double)num4);
			}
			else
			{
				num4 = 0f;
			}
			num *= num4;
			cor_max = num;
			return (short)num2;
		}
		private static int Pitch_ol(Mode mode, GloabFunc.vadState vadSt, float[] signal, int signalOffset, int pit_min, int pit_max, short L_frame, int int_0, short short_0)
		{
			float[] array = new float[144];
			float num = 0f;
			float num2 = 0f;
			float num3 = 0f;
			float num4 = 0f;
			float num5 = 0f;
			float num6 = 0f;
			float num7 = 0f;
			float num8 = 0f;
			float num9 = 0f;
			float[] corr = array;
			GloabFunc.comp_corr(signal, signalOffset, (int)L_frame, pit_max, pit_min, corr, pit_max);
			int num10 = pit_min << 2;
			float num11 = (float)GloabFunc.Lag_max(corr, pit_max, signal, signalOffset, L_frame, pit_max, num10, ref num, int_0, ref num7, ref num4);
			int lag_max = num10 - 1;
			num10 = pit_min << 1;
			float num12 = (float)GloabFunc.Lag_max(corr, pit_max, signal, signalOffset, L_frame, lag_max, num10, ref num2, int_0, ref num8, ref num5);
			lag_max = num10 - 1;
			float num13 = (float)GloabFunc.Lag_max(corr, pit_max, signal, signalOffset, L_frame, lag_max, pit_min, ref num3, int_0, ref num9, ref num6);
			if (num * 0.85f < num2)
			{
				num = num2;
				num11 = num12;
				if (int_0 != 0)
				{
					num7 = num8;
					num4 = num5;
				}
			}
			if (num * 0.85f < num3)
			{
				num11 = num13;
				if (int_0 != 0)
				{
					num7 = num9;
					num4 = num6;
				}
			}
			if (int_0 != 0)
			{
				vadSt.Rmax += num7;
				vadSt.R0 += num4;
			}
			return (int)num11;
		}
		private static int Lag_max_wght(GloabFunc.vadState vadSt, float[] corr, int corrOffset, float[] signal, int signalOffset, int old_lag, ref int cor_max, int wght_flg, ref float gain_flg, int int_0)
		{
			float[] corrweight = DefineConstants.corrweight;
			int num = 250;
			float[] corrweight2 = DefineConstants.corrweight;
			int num2 = 266 - old_lag;
			float num3 = -3.40282347E+38f;
			int num4 = 143;
			float num5;
			if (wght_flg > 0)
			{
				for (int i = 143; i >= 20; i--)
				{
					num5 = corr[corrOffset - i] * corrweight[num--];
					num5 *= corrweight2[num2--];
					if (num5 >= num3)
					{
						num3 = num5;
						num4 = i;
					}
				}
			}
			else
			{
				for (int i = 143; i >= 20; i--)
				{
					num5 = corr[corrOffset - i] * corrweight[num--];
					if (num5 >= num3)
					{
						num3 = num5;
						num4 = i;
					}
				}
			}
			int num6 = signalOffset;
			int num7 = signalOffset - num4;
			num5 = 0f;
			float num8 = 0f;
			int j = 0;
			while (j < 80)
			{
				num5 += signal[num6] * signal[num7];
				num8 += signal[num7] * signal[num7];
				j++;
				num6++;
				num7++;
			}
			if (int_0 != 0)
			{
				vadSt.Rmax += num5;
				vadSt.R0 += num8;
			}
			gain_flg = num5 - num8 * 0.4f;
			cor_max = 0;
			return num4;
		}
		private static int gmed_n(int[] int_0, int indOffset, int int_1)
		{
			int num = 0;
			int[] array = new int[9];
			int[] array2 = new int[9];
			for (int i = 0; i < int_1; i++)
			{
				array2[i] = int_0[indOffset + i];
			}
			for (int i = 0; i < int_1; i++)
			{
				int num2 = -32767;
				for (int j = 0; j < int_1; j++)
				{
					if (array2[j] >= num2)
					{
						num2 = array2[j];
						num = j;
					}
				}
				array2[num] = -32768;
				array[i] = num;
			}
			int num3 = array[int_1 >> 1];
			return int_0[indOffset + num3];
		}
		private static int Pitch_ol_wgh(ref int old_T0_med, ref short wght_flg, ref float ada_w, GloabFunc.vadState vadSt, float[] signal, int signalOffset, int[] old_lags, int old_lagsOffset, float[] ol_gain_flg, int ol_gain_flgOffset, short short_0, int int_0)
		{
			float[] array = new float[144];
			int num = 0;
			float[] corr = array;
			GloabFunc.comp_corr(signal, signalOffset, 80, 143, 20, corr, 143);
			float num2 = ol_gain_flg[ol_gain_flgOffset + (int)short_0];
			int num3 = GloabFunc.Lag_max_wght(vadSt, corr, 143, signal, signalOffset, old_T0_med, ref num, (int)wght_flg, ref num2, int_0);
			ol_gain_flg[ol_gain_flgOffset + (int)short_0] = num2;
			if (ol_gain_flg[ol_gain_flgOffset + (int)short_0] > 0f)
			{
				for (int i = 4; i > 0; i--)
				{
					old_lags[old_lagsOffset + i] = old_lags[old_lagsOffset + i - 1];
				}
				old_lags[old_lagsOffset] = num3;
				old_T0_med = GloabFunc.gmed_n(old_lags, old_lagsOffset, 5);
				ada_w = 1f;
			}
			else
			{
				old_T0_med = num3;
				ada_w *= 0.9f;
			}
			if ((double)ada_w < 0.3)
			{
				wght_flg = 0;
			}
			else
			{
				wght_flg = 1;
			}
			return num3;
		}
		private static void ol_ltp(Mode mode, GloabFunc.vadState vadSt, float[] float_0, int wspOffset, ref int T_op, float[] ol_gain_flg, int ol_gain_flgOffset, ref int old_T0_med, ref short wght_flg, ref float ada_w, int[] old_lags, int old_lagsOffset, int int_0, short short_0)
		{
			if (mode != Mode.MR102)
			{
				ol_gain_flg[ol_gain_flgOffset] = 0f;
				ol_gain_flg[ol_gain_flgOffset + 1] = 0f;
			}
			if (mode != Mode.MR475)
			{
				if (mode != Mode.MR515)
				{
					if (mode <= Mode.MR795)
					{
						T_op = GloabFunc.Pitch_ol(mode, vadSt, float_0, wspOffset, 20, 143, 80, int_0, short_0);
						return;
					}
					if (mode == Mode.MR102)
					{
						T_op = GloabFunc.Pitch_ol_wgh(ref old_T0_med, ref wght_flg, ref ada_w, vadSt, float_0, wspOffset, old_lags, old_lagsOffset, ol_gain_flg, ol_gain_flgOffset, short_0, int_0);
						return;
					}
					T_op = GloabFunc.Pitch_ol(mode, vadSt, float_0, wspOffset, 18, 143, 80, int_0, short_0);
					return;
				}
			}
			T_op = GloabFunc.Pitch_ol(mode, vadSt, float_0, wspOffset, 20, 143, 160, int_0, short_0);
		}
		private static void subframePreProc(Mode mode, float[] gamma1, int gamma1Offset, float[] gamma1_12k2, int gamma1_12k2Offset, float[] gamma2, int gamma2Offset, float[] A, int AOffset, float[] Aq, int AqOffset, float[] speech, int speechOffset, float[] mem_err, int mem_errOffset, float[] mem_w0, int mem_w0Offset, float[] zero, int zeroOffset, float[] ai_zero, int ai_zeroOffset, float[] float_0, int excOffset, float[] float_1, int h1Offset, float[] float_2, int xnOffset, float[] res2, int res2Offset, float[] error, int errorOffset)
		{
			float[] array = new float[11];
			float[] array2 = new float[11];
			float[] float_3 = gamma1;
			int facOffset = gamma1Offset;
			if (mode == Mode.MR122 || mode == Mode.MR102)
			{
				float_3 = gamma1_12k2;
				facOffset = gamma1_12k2Offset;
			}
			GloabFunc.Weight_Ai(A, AOffset, float_3, facOffset, array, 0);
			GloabFunc.Weight_Ai(A, AOffset, gamma2, gamma2Offset, array2, 0);
			GloabFunc.memcpyFloat(ai_zero, ai_zeroOffset, array, 0, 11);
			GloabFunc.Syn_filt(Aq, AqOffset, ai_zero, ai_zeroOffset, float_1, h1Offset, zero, zeroOffset, 0);
			GloabFunc.Syn_filt(array2, 0, float_1, h1Offset, float_1, h1Offset, zero, zeroOffset, 0);
			GloabFunc.Residu(Aq, AqOffset, speech, speechOffset, res2, res2Offset);
			GloabFunc.memcpyFloat(float_0, excOffset, res2, res2Offset, 40);
			GloabFunc.Syn_filt(Aq, AqOffset, float_0, excOffset, error, errorOffset, mem_err, mem_errOffset, 0);
			GloabFunc.Residu(array, 0, error, errorOffset, float_2, xnOffset);
			GloabFunc.Syn_filt(array2, 0, float_2, xnOffset, float_2, xnOffset, mem_w0, mem_w0Offset, 0);
		}
		private static void getRange(int T0, short delta_low, short delta_range, short pitmin, short pitmax, ref int T0_min, ref int T0_max)
		{
			T0_min = T0 - (int)delta_low;
			if (T0_min < (int)pitmin)
			{
				T0_min = (int)pitmin;
			}
			T0_max = T0_min + (int)delta_range;
			if (T0_max > (int)pitmax)
			{
				T0_max = (int)pitmax;
				T0_min = T0_max - (int)delta_range;
			}
		}
		private static void Norm_Corr(float[] float_0, int excOffset, float[] float_1, int xnOffset, float[] float_2, int hOffset, int t_min, int t_max, float[] corr_norm, int corr_normOffset)
		{
			float[] array = new float[40];
			int num = -t_min;
			int num2 = excOffset - t_min;
			for (int i = 0; i < 40; i++)
			{
				float num3 = 0f;
				for (int j = 0; j <= i; j++)
				{
					num3 += float_0[num2 + j] * float_2[hOffset + i - j];
				}
				array[i] = num3;
			}
			for (int j = t_min; j <= t_max; j++)
			{
				float num4 = GloabFunc.Dotproduct40(array, 0, array, 0);
				if (num4 == 0f)
				{
					num4 = 1f;
				}
				else
				{
					num4 = (float)(1.0 / Math.Sqrt((double)num4));
				}
				float num5 = GloabFunc.Dotproduct40(float_1, xnOffset, array, 0);
				corr_norm[corr_normOffset + j] = num5 * num4;
				if (j != t_max)
				{
					num--;
					for (int i = 39; i > 0; i--)
					{
						array[i] = array[i - 1] + float_0[excOffset + num] * float_2[hOffset + i];
					}
					array[0] = float_0[excOffset + num];
				}
			}
		}
		private static float Interpol_3or6(float[] float_0, int xOffset, int frac, short flag3)
		{
			if (flag3 != 0)
			{
				frac <<= 1;
			}
			if (frac < 0)
			{
				frac += 6;
				xOffset--;
			}
			int num = xOffset;
			int num2 = xOffset + 1;
			float[] float_ = DefineConstants.float_1;
			int num3 = frac;
			float[] float_2 = DefineConstants.float_1;
			int num4 = 6 - frac;
			float num5 = 0f;
			int i = 0;
			int num6 = 0;
			while (i < 4)
			{
				num5 += float_0[num - i] * float_[num3 + num6];
				num5 += float_0[num2 + i] * float_2[num4 + num6];
				i++;
				num6 += 6;
			}
			return num5;
		}
		private static void searchFrac(ref int int_0, ref int frac, short last_frac, float[] corr, int corrOffset, short flag3)
		{
			float num = GloabFunc.Interpol_3or6(corr, corrOffset + int_0, frac, flag3);
			for (int i = frac + 1; i <= (int)last_frac; i++)
			{
				float num2 = GloabFunc.Interpol_3or6(corr, corrOffset + int_0, i, flag3);
				if (num2 > num)
				{
					num = num2;
					frac = i;
				}
			}
			if (flag3 == 0)
			{
				if (frac == -3)
				{
					frac = 3;
					int_0--;
					return;
				}
			}
			else
			{
				if (frac == -2)
				{
					frac = 1;
					int_0--;
				}
				if (frac == 2)
				{
					frac = -1;
					int_0++;
				}
			}
		}
		private static int Enc_lag3(int T0, int T0_frac, int T0_prev, int T0_min, int T0_max, short delta_flag, short flag4)
		{
			int result;
			if (delta_flag == 0)
			{
				if (T0 <= 85)
				{
					result = T0 * 3 - 58 + T0_frac;
				}
				else
				{
					result = T0 + 112;
				}
			}
			else
			{
				if (flag4 == 0)
				{
					result = 3 * (T0 - T0_min) + 2 + T0_frac;
				}
				else
				{
					int num = T0_prev;
					if (num - T0_min > 5)
					{
						num = T0_min + 5;
					}
					if (T0_max - num > 4)
					{
						num = T0_max - 4;
					}
					int num2 = T0 + T0 + T0 + T0_frac;
					int num3 = num - 2;
					int num4 = num3 + num3 + num3;
					if (num4 >= num2)
					{
						result = T0 - num + 5;
					}
					else
					{
						num3 = num + 1;
						num3 = num3 + num3 + num3;
						if (num3 > num2)
						{
							result = num2 - num4 + 3;
						}
						else
						{
							result = T0 - num + 11;
						}
					}
				}
			}
			return result;
		}
		private static int Enc_lag6(int T0, int T0_frac, int T0_min, short delta_flag)
		{
			int result;
			if (delta_flag == 0)
			{
				if (T0 <= 94)
				{
					result = T0 * 6 - 105 + T0_frac;
				}
				else
				{
					result = T0 + 368;
				}
			}
			else
			{
				result = 6 * (T0 - T0_min) + 3 + T0_frac;
			}
			return result;
		}
		private static int Pitch_fr(ref int T0_prev_subframe, Mode mode, int[] T_op, int T_opOffset, float[] float_0, int excOffset, float[] float_1, int xnOffset, float[] float_2, int hOffset, short i_subfr, ref int pit_frac, ref short resu3, ref int ana_index)
		{
			float[] array = new float[40];
			int num = 0;
			int num2 = 0;
			short max_frac_lag = (short)DefineConstants.mode_dep_parm[(int)mode].max_frac_lag;
			short flag = (short)DefineConstants.mode_dep_parm[(int)mode].flag3;
			int num3 = (int)DefineConstants.mode_dep_parm[(int)mode].first_frac;
			short last_frac = (short)DefineConstants.mode_dep_parm[(int)mode].last_frac;
			short delta_int_low = (short)DefineConstants.mode_dep_parm[(int)mode].delta_int_low;
			short delta_int_range = (short)DefineConstants.mode_dep_parm[(int)mode].delta_int_range;
			short delta_frc_low = (short)DefineConstants.mode_dep_parm[(int)mode].delta_frc_low;
			short delta_frc_range = (short)DefineConstants.mode_dep_parm[(int)mode].delta_frc_range;
			short pit_min = (short)DefineConstants.mode_dep_parm[(int)mode].pit_min;
			short num4 = 1;
			if (i_subfr != 0)
			{
				if (i_subfr != 80)
				{
					GloabFunc.getRange(T0_prev_subframe, delta_frc_low, delta_frc_range, pit_min, 143, ref num, ref num2);
					goto IL_FF;
				}
			}
			if ((mode != Mode.MR475 && mode != Mode.MR515) || i_subfr != 80)
			{
				num4 = 0;
				short num5 = 1;
				if (i_subfr == 0)
				{
					num5 = 0;
				}
				GloabFunc.getRange(T_op[T_opOffset + (int)num5], delta_int_low, delta_int_range, pit_min, 143, ref num, ref num2);
			}
			else
			{
				GloabFunc.getRange(T0_prev_subframe, delta_frc_low, delta_frc_range, pit_min, 143, ref num, ref num2);
			}
			IL_FF:
			int num6 = num - 4;
			int t_max = num2 + 4;
			float[] array2 = array;
			int num7 = -num6;
			GloabFunc.Norm_Corr(float_0, excOffset, float_1, xnOffset, float_2, hOffset, num6, t_max, array2, num7);
			float num8 = array2[num7 + num];
			int num9 = num;
			for (int i = num + 1; i <= num2; i++)
			{
				if (array2[num7 + i] >= num8)
				{
					num8 = array2[num7 + i];
					num9 = i;
				}
			}
			if (num4 == 0 && num9 > (int)max_frac_lag)
			{
				num3 = 0;
			}
			else
			{
				if (num4 != 0 && (mode == Mode.MR475 || mode == Mode.MR515 || mode == Mode.MR59 || mode == Mode.MR67))
				{
					int num10 = T0_prev_subframe;
					if (num10 - num > 5)
					{
						num10 = num + 5;
					}
					if (num2 - num10 > 4)
					{
						num10 = num2 - 4;
					}
					if (num9 != num10)
					{
						if (num9 != num10 - 1)
						{
							if (num9 == num10 - 2)
							{
								num3 = 0;
								GloabFunc.searchFrac(ref num9, ref num3, last_frac, array2, num7, flag);
								goto IL_211;
							}
							if (num9 == num10 + 1)
							{
								GloabFunc.searchFrac(ref num9, ref num3, 0, array2, num7, flag);
								goto IL_211;
							}
							num3 = 0;
							goto IL_211;
						}
					}
					GloabFunc.searchFrac(ref num9, ref num3, last_frac, array2, num7, flag);
				}
				else
				{
					GloabFunc.searchFrac(ref num9, ref num3, last_frac, array2, num7, flag);
				}
			}
			IL_211:
			if (flag != 0)
			{
				short flag2 = 0;
				if (mode == Mode.MR475 || mode == Mode.MR515 || mode == Mode.MR59 || mode == Mode.MR67)
				{
					flag2 = 1;
				}
				ana_index = GloabFunc.Enc_lag3(num9, num3, T0_prev_subframe, num, num2, num4, flag2);
			}
			else
			{
				ana_index = GloabFunc.Enc_lag6(num9, num3, num, num4);
			}
			T0_prev_subframe = num9;
			resu3 = flag;
			pit_frac = num3;
			return num9;
		}
		private static void Pred_lt_3or6(float[] float_0, int excOffset, int T0, int frac, short flag3)
		{
			int num = excOffset - T0;
			frac = -frac;
			if (flag3 != 0)
			{
				frac <<= 1;
			}
			if (frac < 0)
			{
				frac += 6;
				num--;
			}
			float[] float_ = DefineConstants.float_0;
			int num2 = frac;
			float[] float_2 = DefineConstants.float_0;
			int num3 = 6 - frac;
			for (int i = 0; i < 40; i += 4)
			{
				int num4 = num;
				num++;
				int num5 = num;
				float num6 = float_0[num4] * float_[num2] + float_0[num5] * float_2[num3];
				num6 += float_0[num4 - 1] * float_[num2 + 6] + float_0[num5 + 1] * float_2[num3 + 6];
				num6 += float_0[num4 - 2] * float_[num2 + 12] + float_0[num5 + 2] * float_2[num3 + 12];
				num6 += float_0[num4 - 3] * float_[num2 + 18] + float_0[num5 + 3] * float_2[num3 + 18];
				num6 += float_0[num4 - 4] * float_[num2 + 24] + float_0[num5 + 4] * float_2[num3 + 24];
				num6 += float_0[num4 - 5] * float_[num2 + 30] + float_0[num5 + 5] * float_2[num3 + 30];
				num6 += float_0[num4 - 6] * float_[num2 + 36] + float_0[num5 + 6] * float_2[num3 + 36];
				num6 += float_0[num4 - 7] * float_[num2 + 42] + float_0[num5 + 7] * float_2[num3 + 42];
				num6 += float_0[num4 - 8] * float_[num2 + 48] + float_0[num5 + 8] * float_2[num3 + 48];
				num6 += float_0[num4 - 9] * float_[num2 + 54] + float_0[num5 + 9] * float_2[num3 + 54];
				float_0[excOffset + i] = (float)Math.Floor((double)(num6 + 0.5f));
				num4 = num;
				num++;
				num5 = num;
				num6 = float_0[num4] * float_[num2] + float_0[num5] * float_2[num3];
				num6 += float_0[num4 - 1] * float_[num2 + 6] + float_0[num5 + 1] * float_2[num3 + 6];
				num6 += float_0[num4 - 2] * float_[num2 + 12] + float_0[num5 + 2] * float_2[num3 + 12];
				num6 += float_0[num4 - 3] * float_[num2 + 18] + float_0[num5 + 3] * float_2[num3 + 18];
				num6 += float_0[num4 - 4] * float_[num2 + 24] + float_0[num5 + 4] * float_2[num3 + 24];
				num6 += float_0[num4 - 5] * float_[num2 + 30] + float_0[num5 + 5] * float_2[num3 + 30];
				num6 += float_0[num4 - 6] * float_[num2 + 36] + float_0[num5 + 6] * float_2[num3 + 36];
				num6 += float_0[num4 - 7] * float_[num2 + 42] + float_0[num5 + 7] * float_2[num3 + 42];
				num6 += float_0[num4 - 8] * float_[num2 + 48] + float_0[num5 + 8] * float_2[num3 + 48];
				num6 += float_0[num4 - 9] * float_[num2 + 54] + float_0[num5 + 9] * float_2[num3 + 54];
				float_0[excOffset + i + 1] = (float)Math.Floor((double)(num6 + 0.5f));
				num4 = num;
				num++;
				num5 = num;
				num6 = float_0[num4] * float_[num2] + float_0[num5] * float_2[num3];
				num6 += float_0[num4 - 1] * float_[num2 + 6] + float_0[num5 + 1] * float_2[num3 + 6];
				num6 += float_0[num4 - 2] * float_[num2 + 12] + float_0[num5 + 2] * float_2[num3 + 12];
				num6 += float_0[num4 - 3] * float_[num2 + 18] + float_0[num5 + 3] * float_2[num3 + 18];
				num6 += float_0[num4 - 4] * float_[num2 + 24] + float_0[num5 + 4] * float_2[num3 + 24];
				num6 += float_0[num4 - 5] * float_[num2 + 30] + float_0[num5 + 5] * float_2[num3 + 30];
				num6 += float_0[num4 - 6] * float_[num2 + 36] + float_0[num5 + 6] * float_2[num3 + 36];
				num6 += float_0[num4 - 7] * float_[num2 + 42] + float_0[num5 + 7] * float_2[num3 + 42];
				num6 += float_0[num4 - 8] * float_[num2 + 48] + float_0[num5 + 8] * float_2[num3 + 48];
				num6 += float_0[num4 - 9] * float_[num2 + 54] + float_0[num5 + 9] * float_2[num3 + 54];
				float_0[excOffset + i + 2] = (float)Math.Floor((double)(num6 + 0.5f));
				num4 = num;
				num++;
				num5 = num;
				num6 = float_0[num4] * float_[num2] + float_0[num5] * float_2[num3];
				num6 += float_0[num4 - 1] * float_[num2 + 6] + float_0[num5 + 1] * float_2[num3 + 6];
				num6 += float_0[num4 - 2] * float_[num2 + 12] + float_0[num5 + 2] * float_2[num3 + 12];
				num6 += float_0[num4 - 3] * float_[num2 + 18] + float_0[num5 + 3] * float_2[num3 + 18];
				num6 += float_0[num4 - 4] * float_[num2 + 24] + float_0[num5 + 4] * float_2[num3 + 24];
				num6 += float_0[num4 - 5] * float_[num2 + 30] + float_0[num5 + 5] * float_2[num3 + 30];
				num6 += float_0[num4 - 6] * float_[num2 + 36] + float_0[num5 + 6] * float_2[num3 + 36];
				num6 += float_0[num4 - 7] * float_[num2 + 42] + float_0[num5 + 7] * float_2[num3 + 42];
				num6 += float_0[num4 - 8] * float_[num2 + 48] + float_0[num5 + 8] * float_2[num3 + 48];
				num6 += float_0[num4 - 9] * float_[num2 + 54] + float_0[num5 + 9] * float_2[num3 + 54];
				float_0[excOffset + i + 3] = (float)Math.Floor((double)(num6 + 0.5f));
			}
		}
		private static void Pred_lt_3or6_fixed(int[] int_0, int excOffset, int T0, int frac, int flag3)
		{
			int num = excOffset - T0;
			frac = -frac;
			if (flag3 != 0)
			{
				frac <<= 1;
			}
			if (frac < 0)
			{
				frac += 6;
				num--;
			}
			int[] inter = DefineConstants.inter6;
			int num2 = frac;
			int[] inter2 = DefineConstants.inter6;
			int num3 = 6 - frac;
			for (int i = 0; i < 40; i++)
			{
				int num4 = num;
				num++;
				int num5 = num;
				int num6 = int_0[num4] * inter[num2];
				num6 += int_0[num4 - 1] * inter[num2 + 6];
				num6 += int_0[num4 - 2] * inter[num2 + 12];
				num6 += int_0[num4 - 3] * inter[num2 + 18];
				num6 += int_0[num4 - 4] * inter[num2 + 24];
				num6 += int_0[num4 - 5] * inter[num2 + 30];
				num6 += int_0[num4 - 6] * inter[num2 + 36];
				num6 += int_0[num4 - 7] * inter[num2 + 42];
				num6 += int_0[num4 - 8] * inter[num2 + 48];
				num6 += int_0[num4 - 9] * inter[num2 + 54];
				num6 += int_0[num5] * inter2[num3];
				num6 += int_0[num5 + 1] * inter2[num3 + 6];
				num6 += int_0[num5 + 2] * inter2[num3 + 12];
				num6 += int_0[num5 + 3] * inter2[num3 + 18];
				num6 += int_0[num5 + 4] * inter2[num3 + 24];
				num6 += int_0[num5 + 5] * inter2[num3 + 30];
				num6 += int_0[num5 + 6] * inter2[num3 + 36];
				num6 += int_0[num5 + 7] * inter2[num3 + 42];
				num6 += int_0[num5 + 8] * inter2[num3 + 48];
				num6 += int_0[num5 + 9] * inter2[num3 + 54];
				int_0[excOffset + i] = num6 + 16384 >> 15;
			}
		}
		private static float G_pitch(float[] float_0, int xnOffset, float[] float_1, int y1Offset, float[] gCoeff, int gCoeffOffset)
		{
			float num = GloabFunc.Dotproduct40(float_1, y1Offset, float_1, y1Offset);
			num += 0.01f;
			gCoeff[gCoeffOffset] = num;
			num = GloabFunc.Dotproduct40(float_0, xnOffset, float_1, y1Offset);
			gCoeff[gCoeffOffset + 1] = num;
			float num2 = gCoeff[gCoeffOffset + 1] / gCoeff[gCoeffOffset];
			if ((double)num2 < 0.0)
			{
				num2 = 0f;
			}
			if ((double)num2 > 1.2)
			{
				num2 = 1.2f;
			}
			return num2;
		}
		private static short check_gp_clipping(float[] float_0, int gpOffset, float g_pitch)
		{
			float num = g_pitch;
			for (int i = 0; i < 7; i++)
			{
				num += float_0[gpOffset + i];
			}
			if (num > 7.6f)
			{
				return 1;
			}
			return 0;
		}
		private static short q_gain_pitch(Mode mode, float gp_limit, ref float gain, float[] gain_cand, int gain_candOffset, int[] gain_cind, int gain_cindOffset)
		{
			float num = Math.Abs(gain - DefineConstants.qua_gain_pitch[0]);
			int num2 = 0;
			for (int i = 1; i < 16; i++)
			{
				if (DefineConstants.qua_gain_pitch[i] <= gp_limit)
				{
					float num3 = Math.Abs(gain - DefineConstants.qua_gain_pitch[i]);
					if (num3 < num)
					{
						num = num3;
						num2 = i;
					}
				}
			}
			if (mode == Mode.MR795)
			{
				int num4;
				if (num2 == 0)
				{
					num4 = num2;
				}
				else
				{
					num4 = num2 - 1;
					if (num2 == 15 || DefineConstants.qua_gain_pitch[num2 + 1] > gp_limit)
					{
						num4 = num2 - 2;
					}
				}
				for (int i = 0; i < 3; i++)
				{
					gain_cind[gain_cindOffset + i] = num4;
					gain_cand[gain_candOffset + i] = DefineConstants.qua_gain_pitch[num4];
					num4++;
				}
				gain = DefineConstants.qua_gain_pitch[num2];
			}
			else
			{
				gain = DefineConstants.qua_gain_pitch_MR122[num2];
			}
			return (short)num2;
		}
		private static void cl_ltp(ref int T0_prev_subframe, float[] float_0, int gpOffset, Mode mode, short frame_offset, int[] T_op, int T_opOffset, float[] float_1, int h1Offset, float[] float_2, int excOffset, float[] res2, int res2Offset, float[] float_3, int xnOffset, short lsp_flag, float[] float_4, int xn2Offset, float[] float_5, int y1Offset, ref int T0, ref int T0_frac, ref float gain_pit, float[] gCoeff, int gCoeffOffset, short[] anap, ref int anapOffset, ref float gp_limit)
		{
			int i = 0;
			short flag = 0;
			int[] array = new int[314];
			int[] array2 = array;
			int num = 154;
			T0 = GloabFunc.Pitch_fr(ref T0_prev_subframe, mode, T_op, T_opOffset, float_2, excOffset, float_3, xnOffset, float_1, h1Offset, frame_offset, ref T0_frac, ref flag, ref i);
			anap[anapOffset++] = (short)i;
			for (i = -154; i < 40; i++)
			{
				array2[num + i] = (int)float_2[excOffset + i];
			}
			GloabFunc.Pred_lt_3or6_fixed(array2, num, T0, T0_frac, (int)flag);
			for (i = -154; i < 40; i++)
			{
				float_2[excOffset + i] = (float)array2[num + i];
			}
			for (int j = 0; j < 40; j++)
			{
				float num2 = 0f;
				for (i = 0; i <= j; i++)
				{
					num2 += float_2[excOffset + i] * float_1[h1Offset + j - i];
				}
				float_5[y1Offset + j] = num2;
			}
			gain_pit = GloabFunc.G_pitch(float_3, xnOffset, float_5, y1Offset, gCoeff, gCoeffOffset);
			short num3 = 0;
			gp_limit = 2f;
			if (lsp_flag != 0 && gain_pit > 0.95f)
			{
				num3 = GloabFunc.check_gp_clipping(float_0, gpOffset, gain_pit);
			}
			if (mode != Mode.MR475)
			{
				if (mode != Mode.MR515)
				{
					if (num3 != 0)
					{
						gp_limit = 0.95f;
						gain_pit = 0.95f;
					}
					if (mode == Mode.MR122)
					{
						anap[anapOffset++] = GloabFunc.q_gain_pitch(Mode.MR122, gp_limit, ref gain_pit, null, 0, null, 0);
						goto IL_17D;
					}
					goto IL_17D;
				}
			}
			if ((double)gain_pit > 0.85)
			{
				gain_pit = 0.85f;
			}
			if (num3 != 0)
			{
				gp_limit = 0.95f;
			}
			IL_17D:
			for (i = 0; i < 40; i++)
			{
				float_4[xn2Offset + i] = float_3[xnOffset + i] - float_5[y1Offset + i] * gain_pit;
				res2[res2Offset + i] = res2[res2Offset + i] - float_2[excOffset + i] * gain_pit;
			}
		}
		private static float DotProduct(float[] float_0, int xOffset, float[] float_1, int yOffset, int int_0)
		{
			float num = 0f;
			for (int i = 0; i < int_0; i++)
			{
				num += float_0[xOffset + i] * float_1[yOffset + i];
			}
			return num;
		}
		private static void cor_h_x(float[] float_0, int hOffset, float[] float_1, int xOffset, float[] float_2, int dnOffset)
		{
			float_2[dnOffset] = GloabFunc.Dotproduct40(float_0, hOffset, float_1, xOffset);
			for (int i = 1; i < 40; i++)
			{
				float_2[dnOffset + i] = GloabFunc.DotProduct(float_0, hOffset, float_1, xOffset + i, 40 - i);
			}
		}
		private static void cor_h(float[] float_0, int hOffset, float[] sign, int signOffset, float[,] float_1)
		{
			float num = 0f;
			float_1[0, 0] = GloabFunc.Dotproduct40(float_0, hOffset, float_0, hOffset);
			int num2 = GloabFunc.GetOffset(float_1, 39, 39);
			int num3 = hOffset;
			int num4 = num3 + 39;
			do
			{
				num += float_0[num3] * float_0[num3];
				num3++;
				GloabFunc.Set2D(float_1, num2, num);
				num2 -= 41;
				num += float_0[num3] * float_0[num3];
				num3++;
				GloabFunc.Set2D(float_1, num2, num);
				num2 -= 41;
				num += float_0[num3] * float_0[num3];
				num3++;
				GloabFunc.Set2D(float_1, num2, num);
				num2 -= 41;
				num += float_0[num3] * float_0[num3];
				num3++;
				GloabFunc.Set2D(float_1, num2, num);
				num2 -= 41;
				num += float_0[num3] * float_0[num3];
				num3++;
				GloabFunc.Set2D(float_1, num2, num);
				num2 -= 41;
				num += float_0[num3] * float_0[num3];
				num3++;
				GloabFunc.Set2D(float_1, num2, num);
				num2 -= 41;
				num += float_0[num3] * float_0[num3];
				num3++;
				GloabFunc.Set2D(float_1, num2, num);
				num2 -= 41;
				num += float_0[num3] * float_0[num3];
				num3++;
				GloabFunc.Set2D(float_1, num2, num);
				num2 -= 41;
				num += float_0[num3] * float_0[num3];
				num3++;
				GloabFunc.Set2D(float_1, num2, num);
				num2 -= 41;
				num += float_0[num3] * float_0[num3];
				num3++;
				GloabFunc.Set2D(float_1, num2, num);
				num2 -= 41;
				num += float_0[num3] * float_0[num3];
				num3++;
				GloabFunc.Set2D(float_1, num2, num);
				num2 -= 41;
				num += float_0[num3] * float_0[num3];
				num3++;
				GloabFunc.Set2D(float_1, num2, num);
				num2 -= 41;
				num += float_0[num3] * float_0[num3];
				num3++;
				GloabFunc.Set2D(float_1, num2, num);
				num2 -= 41;
			}
			while (num3 < num4);
			int num5 = 1;
			for (int i = 9; i >= 0; i--)
			{
				int num6 = GloabFunc.GetOffset(float_1, 39, 39);
				int num7 = GloabFunc.GetOffset(float_1, 39, 39);
				num7 -= num5;
				num6 -= 40 * num5;
				int num8 = signOffset + 39;
				int num9 = signOffset + 39;
				num8 -= num5;
				num = 0f;
				num3 = hOffset;
				for (int j = 0; j < i; j++)
				{
					num += float_0[num3] * float_0[num3 + num5];
					num3++;
					float newValue = num * sign[num8] * sign[num9];
					GloabFunc.Set2D(float_1, num6, newValue);
					GloabFunc.Set2D(float_1, num7, newValue);
					num6 -= 41;
					num7 -= 41;
					num8--;
					num9--;
					num += float_0[num3] * float_0[num3 + num5];
					num3++;
					newValue = num * sign[num8] * sign[num9];
					GloabFunc.Set2D(float_1, num6, newValue);
					GloabFunc.Set2D(float_1, num7, newValue);
					num6 -= 41;
					num7 -= 41;
					num8--;
					num9--;
					num += float_0[num3] * float_0[num3 + num5];
					num3++;
					newValue = num * sign[num8] * sign[num9];
					GloabFunc.Set2D(float_1, num6, newValue);
					GloabFunc.Set2D(float_1, num7, newValue);
					num6 -= 41;
					num7 -= 41;
					num8--;
					num9--;
					num += float_0[num3] * float_0[num3 + num5];
					num3++;
					newValue = num * sign[num8] * sign[num9];
					GloabFunc.Set2D(float_1, num6, newValue);
					GloabFunc.Set2D(float_1, num7, newValue);
					num6 -= 41;
					num7 -= 41;
					num8--;
					num9--;
				}
				num += float_0[num3] * float_0[num3 + num5];
				num3++;
				float newValue2 = num * sign[num8] * sign[num9];
				GloabFunc.Set2D(float_1, num6, newValue2);
				GloabFunc.Set2D(float_1, num7, newValue2);
				num6 -= 41;
				num7 -= 41;
				num8--;
				num9--;
				num += float_0[num3] * float_0[num3 + num5];
				num3++;
				newValue2 = num * sign[num8] * sign[num9];
				GloabFunc.Set2D(float_1, num6, newValue2);
				GloabFunc.Set2D(float_1, num7, newValue2);
				num6 -= 41;
				num7 -= 41;
				num8--;
				num9--;
				num += float_0[num3] * float_0[num3 + num5];
				newValue2 = num * sign[num8] * sign[num9];
				GloabFunc.Set2D(float_1, num6, newValue2);
				GloabFunc.Set2D(float_1, num7, newValue2);
				num5++;
				num7 = GloabFunc.GetOffset(float_1, 39, 39);
				num6 = GloabFunc.GetOffset(float_1, 39, 39);
				num7 -= num5;
				num6 -= 40 * num5;
				num8 = signOffset + 39;
				num9 = signOffset + 39;
				num8 -= num5;
				num = 0f;
				num3 = hOffset;
				for (int j = 0; j < i; j++)
				{
					num += float_0[num3] * float_0[num3 + num5];
					num3++;
					newValue2 = num * sign[num8] * sign[num9];
					GloabFunc.Set2D(float_1, num6, newValue2);
					GloabFunc.Set2D(float_1, num7, newValue2);
					num6 -= 41;
					num7 -= 41;
					num8--;
					num9--;
					num += float_0[num3] * float_0[num3 + num5];
					num3++;
					newValue2 = num * sign[num8] * sign[num9];
					GloabFunc.Set2D(float_1, num6, newValue2);
					GloabFunc.Set2D(float_1, num7, newValue2);
					num6 -= 41;
					num7 -= 41;
					num8--;
					num9--;
					num += float_0[num3] * float_0[num3 + num5];
					num3++;
					newValue2 = num * sign[num8] * sign[num9];
					GloabFunc.Set2D(float_1, num6, newValue2);
					GloabFunc.Set2D(float_1, num7, newValue2);
					num6 -= 41;
					num7 -= 41;
					num8--;
					num9--;
					num += float_0[num3] * float_0[num3 + num5];
					num3++;
					newValue2 = num * sign[num8] * sign[num9];
					GloabFunc.Set2D(float_1, num6, newValue2);
					GloabFunc.Set2D(float_1, num7, newValue2);
					num6 -= 41;
					num7 -= 41;
					num8--;
					num9--;
				}
				num += float_0[num3] * float_0[num3 + num5];
				num3++;
				newValue2 = num * sign[num8] * sign[num9];
				GloabFunc.Set2D(float_1, num6, newValue2);
				GloabFunc.Set2D(float_1, num7, newValue2);
				num6 -= 41;
				num7 -= 41;
				num8--;
				num9--;
				num += float_0[num3] * float_0[num3 + num5];
				newValue2 = num * sign[num8] * sign[num9];
				GloabFunc.Set2D(float_1, num6, newValue2);
				GloabFunc.Set2D(float_1, num7, newValue2);
				num5++;
				num7 = GloabFunc.GetOffset(float_1, 39, 39);
				num6 = GloabFunc.GetOffset(float_1, 39, 39);
				num7 -= num5;
				num6 -= 40 * num5;
				num8 = signOffset + 39;
				num9 = signOffset + 39;
				num8 -= num5;
				num = 0f;
				num3 = hOffset;
				for (int j = 0; j < i; j++)
				{
					num += float_0[num3] * float_0[num3 + num5];
					num3++;
					newValue2 = num * sign[num8] * sign[num9];
					GloabFunc.Set2D(float_1, num6, newValue2);
					GloabFunc.Set2D(float_1, num7, newValue2);
					num6 -= 41;
					num7 -= 41;
					num8--;
					num9--;
					num += float_0[num3] * float_0[num3 + num5];
					num3++;
					newValue2 = num * sign[num8] * sign[num9];
					GloabFunc.Set2D(float_1, num6, newValue2);
					GloabFunc.Set2D(float_1, num7, newValue2);
					num6 -= 41;
					num7 -= 41;
					num8--;
					num9--;
					num += float_0[num3] * float_0[num3 + num5];
					num3++;
					newValue2 = num * sign[num8] * sign[num9];
					GloabFunc.Set2D(float_1, num6, newValue2);
					GloabFunc.Set2D(float_1, num7, newValue2);
					num6 -= 41;
					num7 -= 41;
					num8--;
					num9--;
					num += float_0[num3] * float_0[num3 + num5];
					num3++;
					newValue2 = num * sign[num8] * sign[num9];
					GloabFunc.Set2D(float_1, num6, newValue2);
					GloabFunc.Set2D(float_1, num7, newValue2);
					num6 -= 41;
					num7 -= 41;
					num8--;
					num9--;
				}
				num += float_0[num3] * float_0[num3 + num5];
				newValue2 = num * sign[num8] * sign[num9];
				GloabFunc.Set2D(float_1, num6, newValue2);
				GloabFunc.Set2D(float_1, num7, newValue2);
				num5++;
				num7 = GloabFunc.GetOffset(float_1, 39, 39);
				num6 = GloabFunc.GetOffset(float_1, 39, 39);
				num7 -= num5;
				num6 -= 40 * num5;
				num8 = signOffset + 39;
				num9 = signOffset + 39;
				num8 -= num5;
				num = 0f;
				num3 = hOffset;
				for (int j = 0; j < i; j++)
				{
					num += float_0[num3] * float_0[num3 + num5];
					num3++;
					newValue2 = num * sign[num8] * sign[num9];
					GloabFunc.Set2D(float_1, num6, newValue2);
					GloabFunc.Set2D(float_1, num7, newValue2);
					num6 -= 41;
					num7 -= 41;
					num8--;
					num9--;
					num += float_0[num3] * float_0[num3 + num5];
					num3++;
					newValue2 = num * sign[num8] * sign[num9];
					GloabFunc.Set2D(float_1, num6, newValue2);
					GloabFunc.Set2D(float_1, num7, newValue2);
					num6 -= 41;
					num7 -= 41;
					num8--;
					num9--;
					num += float_0[num3] * float_0[num3 + num5];
					num3++;
					newValue2 = num * sign[num8] * sign[num9];
					GloabFunc.Set2D(float_1, num6, newValue2);
					GloabFunc.Set2D(float_1, num7, newValue2);
					num6 -= 41;
					num7 -= 41;
					num8--;
					num9--;
					num += float_0[num3] * float_0[num3 + num5];
					num3++;
					newValue2 = num * sign[num8] * sign[num9];
					GloabFunc.Set2D(float_1, num6, newValue2);
					GloabFunc.Set2D(float_1, num7, newValue2);
					num6 -= 41;
					num7 -= 41;
					num8--;
					num9--;
				}
				num5++;
			}
		}
		private static void search_2i40_9bits(short subNr, float[] float_0, int dnOffset, float[,] float_1, int[] codvec, int codvecOffset)
		{
			short[] array = new short[2];
			float num = -1f;
			float num2 = 1f;
			for (int i = 0; i < 2; i++)
			{
				codvec[codvecOffset + i] = i;
			}
			for (short num3 = 0; num3 < 2; num3 += 1)
			{
				array[0] = DefineConstants.startPos[((int)subNr << 1) + ((int)num3 << 3)];
				array[1] = DefineConstants.startPos[((int)subNr << 1) + 1 + ((int)num3 << 3)];
				for (int j = (int)array[0]; j < 40; j += 5)
				{
					float num4 = float_0[dnOffset + j];
					float num5 = float_1[j, j];
					float num6 = -1f;
					float num7 = 1f;
					int num8 = (int)array[1];
					for (int k = (int)array[1]; k < 40; k += 5)
					{
						float num9 = num4 + float_0[dnOffset + k];
						float num10 = num5 + float_1[k, k] + 2f * float_1[j, k];
						float num11 = num9 * num9;
						if (num7 * num11 > num6 * num10)
						{
							num6 = num11;
							num7 = num10;
							num8 = k;
						}
					}
					if (num2 * num6 > num * num7)
					{
						num = num6;
						num2 = num7;
						codvec[codvecOffset] = j;
						codvec[codvecOffset + 1] = num8;
					}
				}
			}
		}
		private static void build_code_2i40_9bits(short subNr, int[] codvec, int codvecOffset, float[] dn_sign, int dn_signOffset, float[] float_0, int codOffset, float[] float_1, int hOffset, float[] float_2, int yOffset, short[] anap, int anapOffset)
		{
			int[] array = new int[2];
			int num = 0;
			int num2 = 0;
			sbyte[] trackTable = DefineConstants.trackTable;
			int num3 = (int)subNr + ((int)subNr << 2);
			GloabFunc.memsetFloat(float_0, codOffset, 0f, 160);
			for (int i = 0; i < 2; i++)
			{
				int j = codvec[codvecOffset + i];
				int num4 = (int)dn_sign[dn_signOffset + j];
				int num5 = j / 5;
				int num6 = j % 5;
				if (trackTable[num3 + num6] == 0)
				{
					if (i == 0)
					{
						num6 = 0;
					}
					else
					{
						num6 = 1;
						num5 <<= 3;
					}
				}
				else
				{
					if (i == 0)
					{
						num6 = 0;
						num5 += 64;
					}
					else
					{
						num6 = 1;
						num5 <<= 3;
					}
				}
				if (num4 > 0)
				{
					float_0[codOffset + j] = 0.9998779f;
					array[i] = 1;
					num2 += 1 << num6;
				}
				else
				{
					float_0[codOffset + j] = -1f;
					array[i] = -1;
				}
				num += num5;
			}
			int num7 = hOffset - codvec[codvecOffset];
			int num8 = hOffset - codvec[codvecOffset + 1];
			for (int j = 0; j < 40; j++)
			{
				float num9 = float_1[num7++] * (float)array[0];
				num9 += float_1[num8++] * (float)array[1];
				float_2[yOffset + j] = num9;
			}
			anap[anapOffset] = (short)num;
			anap[anapOffset + 1] = (short)num2;
		}
		private static void code_2i40_9bits(short subNr, float[] float_0, int xOffset, float[] float_1, int hOffset, int T0, float pitch_sharp, float[] code, int codeOffset, float[] float_2, int yOffset, short[] anap, int anapOffset)
		{
			float[,] float_3 = new float[40, 40];
			float[] array = new float[40];
			float[] array2 = new float[40];
			float[] float_4 = new float[40];
			int[] codvec = new int[2];
			if (T0 < 40 && pitch_sharp != 0f)
			{
				for (int i = T0; i < 40; i++)
				{
					float_1[hOffset + i] += float_1[hOffset + i - T0] * pitch_sharp;
				}
			}
			GloabFunc.cor_h_x(float_1, hOffset, float_0, xOffset, array, 0);
			GloabFunc.set_sign(array, 0, array2, 0, float_4, 0, 8);
			GloabFunc.cor_h(float_1, hOffset, array2, 0, float_3);
			GloabFunc.search_2i40_9bits(subNr, array, 0, float_3, codvec, 0);
			GloabFunc.build_code_2i40_9bits(subNr, codvec, 0, array2, 0, code, codeOffset, float_1, hOffset, float_2, yOffset, anap, anapOffset);
			if (T0 < 40 && pitch_sharp != 0f)
			{
				for (int i = T0; i < 40; i++)
				{
					code[codeOffset + i] += code[codeOffset + i - T0] * pitch_sharp;
				}
			}
		}
		private static void search_2i40_11bits(float[] float_0, int dnOffset, float[,] float_1, int[] codvec, int codvecOffset)
		{
			short[] array = new short[2];
			float num = -1f;
			double num2 = 1.0;
			for (int i = 0; i < 2; i++)
			{
				codvec[codvecOffset + i] = i;
			}
			for (short num3 = 0; num3 < 2; num3 += 1)
			{
				for (short num4 = 0; num4 < 4; num4 += 1)
				{
					array[0] = DefineConstants.startPos1[(int)num3];
					array[1] = DefineConstants.startPos2[(int)num4];
					for (int j = (int)array[0]; j < 40; j += 5)
					{
						float num5 = float_0[dnOffset + j];
						double num6 = (double)(float_1[j, j] * 0.25f);
						float num7 = -1f;
						double num8 = 1.0;
						int num9 = (int)array[1];
						for (int k = (int)array[1]; k < 40; k += 5)
						{
							float num10 = num5 + float_0[dnOffset + k];
							double num11 = num6 + (double)(float_1[k, k] * 0.25f);
							num11 += (double)(float_1[j, k] * 0.5f);
							float num12 = num10 * num10;
							if (num8 * (double)num12 > (double)num7 * num11)
							{
								num7 = num12;
								num8 = num11;
								num9 = k;
							}
						}
						if (num2 * (double)num7 > (double)num * num8)
						{
							num = num7;
							num2 = num8;
							codvec[codvecOffset] = j;
							codvec[codvecOffset + 1] = num9;
						}
					}
				}
			}
		}
		private static void build_code_2i40_11bits(int[] codvec, int codvecOffset, float[] dn_sign, int dn_signOffset, float[] float_0, int codOffset, float[] float_1, int hOffset, float[] float_2, int yOffset, short[] anap, int anapOffset)
		{
			int[] array = new int[2];
			int num = 0;
			int num2 = 0;
			GloabFunc.memsetFloat(float_0, codOffset, 0f, 160);
			for (int i = 0; i < 2; i++)
			{
				int j = codvec[codvecOffset + i];
				int num3 = (int)((short)dn_sign[dn_signOffset + j]);
				int num4 = j / 5;
				int num5 = j % 5;
				if (num5 == 0)
				{
					num5 = 1;
					num4 <<= 6;
				}
				else
				{
					if (num5 == 1)
					{
						if (i == 0)
						{
							num5 = 0;
							num4 <<= 1;
						}
						else
						{
							num5 = 1;
							num4 = (num4 << 6) + 16;
						}
					}
					else
					{
						if (num5 == 2)
						{
							num5 = 1;
							num4 = (num4 << 6) + 32;
						}
						else
						{
							if (num5 == 3)
							{
								num5 = 0;
								num4 = (num4 << 1) + 1;
							}
							else
							{
								if (num5 == 4)
								{
									num5 = 1;
									num4 = (num4 << 6) + 48;
								}
							}
						}
					}
				}
				if (num3 > 0)
				{
					float_0[codOffset + j] = 0.9998779f;
					array[i] = 1;
					num2 += 1 << num5;
				}
				else
				{
					float_0[codOffset + j] = -1f;
					array[i] = -1;
				}
				num += num4;
			}
			int num6 = hOffset - codvec[codvecOffset];
			int num7 = hOffset - codvec[codvecOffset + 1];
			for (int j = 0; j < 40; j++)
			{
				double num8 = (double)(float_1[num6++] * (float)array[0]);
				num8 += (double)(float_1[num7++] * (float)array[1]);
				float_2[yOffset + j] = (float)num8;
			}
			anap[anapOffset] = (short)num;
			anap[anapOffset + 1] = (short)num2;
		}
		private static void code_2i40_11bits(float[] float_0, int xOffset, float[] float_1, int hOffset, int T0, float pitch_sharp, float[] code, int codeOffset, float[] float_2, int yOffset, short[] anap, int anapOffset)
		{
			float[,] float_3 = new float[40, 40];
			float[] array = new float[40];
			float[] float_4 = new float[40];
			float[] array2 = new float[40];
			int[] codvec = new int[2];
			if (T0 < 40 && pitch_sharp != 0f)
			{
				for (int i = T0; i < 40; i++)
				{
					float_1[hOffset + i] = float_1[hOffset + i] + float_1[hOffset + i - T0] * pitch_sharp;
				}
			}
			GloabFunc.cor_h_x(float_1, hOffset, float_0, xOffset, array, 0);
			GloabFunc.set_sign(array, 0, array2, 0, float_4, 0, 8);
			GloabFunc.cor_h(float_1, hOffset, array2, 0, float_3);
			GloabFunc.search_2i40_11bits(array, 0, float_3, codvec, 0);
			GloabFunc.build_code_2i40_11bits(codvec, 0, array2, 0, code, codeOffset, float_1, hOffset, float_2, yOffset, anap, anapOffset);
			if (T0 < 40 && pitch_sharp != 0f)
			{
				for (int i = T0; i < 40; i++)
				{
					code[codeOffset + i] = code[codeOffset + i] + code[codeOffset + i - T0] * pitch_sharp;
				}
			}
		}
		private static void search_3i40(float[] float_0, int dnOffset, float[] float_1, int dn2Offset, float[,] float_2, int[] codvec, int codvecOffset)
		{
			int[] array = new int[3];
			float num = -1f;
			float num2 = 1f;
			for (int i = 1; i < 4; i += 2)
			{
				for (int j = 2; j < 5; j += 2)
				{
					array[0] = 0;
					array[1] = i;
					array[2] = j;
					for (int k = 0; k < 3; k++)
					{
						for (int l = array[0]; l < 40; l += 5)
						{
							if (float_1[dn2Offset + l] >= 0f)
							{
								float num3 = float_0[dnOffset + l];
								float num4 = float_2[l, l];
								float num5 = -1f;
								float num6 = 1f;
								float num7 = 0f;
								int num8 = array[1];
								int num9 = array[1];
								int num10 = GloabFunc.GetOffset(float_2, num9, num9);
								int num11 = GloabFunc.GetOffset(float_2, l, num9);
								int num12 = dnOffset + num9;
								int num13 = dnOffset + 40;
								do
								{
									float num14 = num3 + float_0[num12];
									float num15 = num4 + GloabFunc.Get2D(float_2, num10) + 2f * GloabFunc.Get2D(float_2, num11);
									float num16 = num14 * num14;
									if (num6 * num16 > num5 * num15)
									{
										num5 = num16;
										num7 = num14;
										num6 = num15;
										num8 = (int)((short)(num12 - dnOffset));
									}
									num12 += 5;
									num10 += 205;
									num11 += 5;
								}
								while (num12 < num13);
								num9 = num8;
								num3 = num7;
								num4 = num6;
								num5 = -1f;
								num6 = 1f;
								num8 = array[2];
								int num17 = array[2];
								int num18 = GloabFunc.GetOffset(float_2, num17, num17);
								num10 = GloabFunc.GetOffset(float_2, num9, num17);
								num11 = GloabFunc.GetOffset(float_2, l, num17);
								num12 = dnOffset + num17;
								do
								{
									float num14 = num3 + float_0[num12];
									float num15 = num4 + GloabFunc.Get2D(float_2, num18) + 2f * (GloabFunc.Get2D(float_2, num10) + GloabFunc.Get2D(float_2, num11));
									float num16 = num14 * num14;
									if (num6 * num16 > num5 * num15)
									{
										num5 = num16;
										num6 = num15;
										num8 = (int)((short)(num12 - dnOffset));
									}
									num12 += 5;
									num18 += 205;
									num10 += 5;
									num11 += 5;
								}
								while (num12 < num13);
								num17 = num8;
								if (num2 * num5 > num * num6)
								{
									num = num5;
									num2 = num6;
									codvec[codvecOffset] = l;
									codvec[codvecOffset + 1] = num9;
									codvec[codvecOffset + 2] = num17;
								}
							}
						}
						int num19 = array[2];
						array[2] = array[1];
						array[1] = array[0];
						array[0] = num19;
					}
				}
			}
		}
		private static void build_code_3i40_14bits(int[] codvec, int codvecOffset, float[] dn_sign, int dn_signOffset, float[] float_0, int codOffset, float[] float_1, int hOffset, float[] float_2, int yOffset, short[] anap, int anapOffset)
		{
			float[] array = new float[3];
			GloabFunc.memsetFloat(float_0, codOffset, 0f, 160);
			int num = 0;
			int num2 = 0;
			for (int i = 0; i < 3; i++)
			{
				int j = codvec[codvecOffset + i];
				int num3 = (int)((short)dn_sign[dn_signOffset + j]);
				int num4 = j / 5;
				int num5 = j % 5;
				if (num5 == 1)
				{
					num4 <<= 4;
				}
				else
				{
					if (num5 == 2)
					{
						num5 = 2;
						num4 <<= 8;
					}
					else
					{
						if (num5 == 3)
						{
							num5 = 1;
							num4 = (num4 << 4) + 8;
						}
						else
						{
							if (num5 == 4)
							{
								num5 = 2;
								num4 = (num4 << 8) + 128;
							}
						}
					}
				}
				if (num3 > 0)
				{
					float_0[codOffset + j] = 0.9998779f;
					array[i] = 1f;
					num2 += 1 << num5;
				}
				else
				{
					float_0[codOffset + j] = -1f;
					array[i] = -1f;
				}
				num += num4;
			}
			int num6 = hOffset - codvec[codvecOffset];
			int num7 = hOffset - codvec[codvecOffset + 1];
			int num8 = hOffset - codvec[codvecOffset + 2];
			for (int j = 0; j < 40; j++)
			{
				double num9 = (double)(float_1[num6++] * array[0]);
				num9 += (double)(float_1[num7++] * array[1]);
				num9 += (double)(float_1[num8++] * array[2]);
				float_2[yOffset + j] = (float)num9;
			}
			anap[anapOffset] = (short)num;
			anap[anapOffset + 1] = (short)num2;
		}
		private static void code_3i40_14bits(float[] float_0, int xOffset, float[] float_1, int hOffset, int T0, float pitch_sharp, float[] code, int codeOffset, float[] float_2, int yOffset, short[] anap, int anapOffset)
		{
			float[,] array = new float[40, 40];
			float[] array2 = new float[40];
			float[] float_3 = new float[40];
			float[] array3 = new float[40];
			int[] codvec = new int[3];
			if (T0 < 40 && pitch_sharp != 0f)
			{
				for (int i = T0; i < 40; i++)
				{
					float_1[hOffset + i] = float_1[hOffset + i] + float_1[hOffset + i - T0] * pitch_sharp;
				}
			}
			GloabFunc.cor_h_x(float_1, hOffset, float_0, xOffset, array2, 0);
			GloabFunc.set_sign(array2, 0, array3, 0, float_3, 0, 6);
			GloabFunc.cor_h(float_1, hOffset, array3, 0, array);
			GloabFunc.search_3i40(array2, 0, float_3, 0, array, codvec, 0);
			GloabFunc.build_code_3i40_14bits(codvec, 0, array3, 0, code, codeOffset, float_1, hOffset, float_2, yOffset, anap, anapOffset);
			if (T0 < 40 && pitch_sharp != 0f)
			{
				for (int i = T0; i < 40; i++)
				{
					code[codeOffset + i] = code[codeOffset + i] + code[codeOffset + i - T0] * pitch_sharp;
				}
			}
		}
		private static void search_4i40(float[] float_0, int dnOffset, float[] float_1, int dn2Offset, float[,] float_2, int[] codvec, int codvecOffset)
		{
			int[] array = new int[4];
			float num = -1f;
			double num2 = 1.0;
			for (int i = 0; i < 4; i++)
			{
				codvec[codvecOffset + i] = i;
			}
			for (int j = 3; j < 5; j++)
			{
				array[0] = 0;
				array[1] = 1;
				array[2] = 2;
				array[3] = j;
				for (int i = 0; i < 4; i++)
				{
					for (int k = array[0]; k < 40; k += 5)
					{
						if (float_1[dn2Offset + k] >= 0f)
						{
							float num3 = float_0[dnOffset + k];
							double num4 = (double)(float_2[k, k] * 0.25f);
							float num5 = -1f;
							double num6 = 1.0;
							float num7 = 0f;
							int num8 = array[1];
							int l;
							for (l = array[1]; l < 40; l += 5)
							{
								float num9 = num3 + float_0[dnOffset + l];
								double num10 = num4 + (double)(float_2[l, l] * 0.25f);
								num10 += (double)(float_2[k, l] * 0.5f);
								float num11 = num9 * num9;
								if (num6 * (double)num11 > (double)num5 * num10)
								{
									num5 = num11;
									num7 = num9;
									num6 = num10;
									num8 = l;
								}
							}
							l = num8;
							num3 = num7;
							num4 = num6 * 0.25;
							num5 = -1f;
							num6 = 1.0;
							num7 = 0f;
							num8 = array[2];
							int m;
							for (m = array[2]; m < 40; m += 5)
							{
								float num9 = num3 + float_0[dnOffset + m];
								double num10 = num4 + (double)(float_2[m, m] * 0.0625f);
								num10 += (double)(float_2[l, m] * 0.125f);
								num10 += (double)(float_2[k, m] * 0.125f);
								float num11 = num9 * num9;
								if (num6 * (double)num11 > (double)num5 * num10)
								{
									num5 = num11;
									num7 = num9;
									num6 = num10;
									num8 = m;
								}
							}
							m = num8;
							num3 = num7;
							num4 = num6;
							num5 = -1f;
							num6 = 1.0;
							num8 = array[3];
							for (int n = array[3]; n < 40; n += 5)
							{
								float num9 = num3 + float_0[dnOffset + n];
								double num10 = num4 + (double)(float_2[n, n] * 0.0625f);
								num10 += (double)(float_2[m, n] * 0.125f);
								num10 += (double)(float_2[l, n] * 0.125f);
								num10 += (double)(float_2[k, n] * 0.125f);
								float num11 = num9 * num9;
								if (num6 * (double)num11 > (double)num5 * num10)
								{
									num5 = num11;
									num6 = num10;
									num8 = n;
								}
							}
							if (num2 * (double)num5 > (double)num * num6)
							{
								num = num5;
								num2 = num6;
								codvec[codvecOffset] = k;
								codvec[codvecOffset + 1] = l;
								codvec[codvecOffset + 2] = m;
								codvec[codvecOffset + 3] = num8;
							}
						}
					}
					int num12 = array[3];
					array[3] = array[2];
					array[2] = array[1];
					array[1] = array[0];
					array[0] = num12;
				}
			}
		}
		private static void build_code_4i40(int[] codvec, int codvecOffset, float[] dn_sign, int dn_signOffset, float[] float_0, int codOffset, float[] float_1, int hOffset, float[] float_2, int yOffset, short[] anap, int anapOffset)
		{
			int[] array = new int[4];
			int num = 0;
			int num2 = 0;
			GloabFunc.memsetFloat(float_0, codOffset, 0f, 160);
			for (int i = 0; i < 4; i++)
			{
				int j = codvec[codvecOffset + i];
				int num3 = (int)((short)dn_sign[dn_signOffset + j]);
				int num4 = j / 5;
				int num5 = j % 5;
				num4 = (int)DefineConstants.gray[num4];
				if (num5 == 1)
				{
					num4 <<= 3;
				}
				else
				{
					if (num5 == 2)
					{
						num4 <<= 6;
					}
					else
					{
						if (num5 == 3)
						{
							num4 <<= 10;
						}
						else
						{
							if (num5 == 4)
							{
								num5 = 3;
								num4 = (num4 << 10) + 512;
							}
						}
					}
				}
				if (num3 > 0)
				{
					float_0[codOffset + j] = 0.9998779f;
					array[i] = 1;
					num2 += 1 << num5;
				}
				else
				{
					float_0[codOffset + j] = -1f;
					array[i] = -1;
				}
				num += num4;
			}
			int num6 = hOffset - codvec[codvecOffset];
			int num7 = hOffset - codvec[codvecOffset + 1];
			int num8 = hOffset - codvec[codvecOffset + 2];
			int num9 = hOffset - codvec[codvecOffset + 3];
			for (int j = 0; j < 40; j++)
			{
				double num10 = (double)(float_1[num6++] * (float)array[0]);
				num10 += (double)(float_1[num7++] * (float)array[1]);
				num10 += (double)(float_1[num8++] * (float)array[2]);
				num10 += (double)(float_1[num9++] * (float)array[3]);
				float_2[yOffset + j] = (float)num10;
			}
			anap[anapOffset] = (short)num;
			anap[anapOffset + 1] = (short)num2;
		}
		private static void code_4i40_17bits(float[] float_0, int xOffset, float[] float_1, int hOffset, int T0, float pitch_sharp, float[] code, int codeOffset, float[] float_2, int yOffset, short[] anap, int anapOffset)
		{
			float[,] array = new float[40, 40];
			float[] array2 = new float[40];
			float[] float_3 = new float[40];
			float[] array3 = new float[40];
			int[] codvec = new int[4];
			if (T0 < 40 && pitch_sharp != 0f)
			{
				for (int i = T0; i < 40; i++)
				{
					float_1[hOffset + i] = float_1[hOffset + i] + float_1[hOffset + i - T0] * pitch_sharp;
				}
			}
			GloabFunc.cor_h_x(float_1, hOffset, float_0, xOffset, array2, 0);
			GloabFunc.set_sign(array2, 0, array3, 0, float_3, 0, 4);
			GloabFunc.cor_h(float_1, hOffset, array3, 0, array);
			GloabFunc.search_4i40(array2, 0, float_3, 0, array, codvec, 0);
			GloabFunc.build_code_4i40(codvec, 0, array3, 0, code, codeOffset, float_1, hOffset, float_2, yOffset, anap, anapOffset);
			if (T0 < 40 && pitch_sharp != 0f)
			{
				for (int i = T0; i < 40; i++)
				{
					code[codeOffset + i] = code[codeOffset + i] + code[codeOffset + i - T0] * pitch_sharp;
				}
			}
		}
		private static void search_8i40(float[] float_0, int dnOffset, float[,] float_1, int[] ipos, int iposOffset, int[] pos_max, int pos_maxOffset, int[] codvec, int codvecOffset)
		{
			float[] array = new float[40];
			int num = dnOffset + 39;
			int num2 = pos_max[pos_maxOffset + ipos[iposOffset]];
			float num3 = -1f;
			float num4 = 1f;
			for (int i = 0; i < 8; i++)
			{
				codvec[codvecOffset + i] = i;
			}
			int offset = GloabFunc.GetOffset(float_1, num2, num2);
			for (int i = 1; i < 5; i++)
			{
				int num5 = pos_max[pos_maxOffset + ipos[iposOffset + 1]];
				int num6 = ipos[iposOffset + 2];
				int num7 = ipos[iposOffset + 3];
				int num8 = ipos[iposOffset + 4];
				int num9 = ipos[iposOffset + 5];
				int num10 = ipos[iposOffset + 6];
				int num11 = ipos[iposOffset + 7];
				float num12 = float_0[dnOffset + num2] + float_0[dnOffset + num5];
				float num13 = GloabFunc.Get2D(float_1, offset) + float_1[num5, num5] + 2f * float_1[num2, num5];
				float[] array2 = array;
				int num14 = num7;
				int num15 = GloabFunc.GetOffset(float_1, num2, num7);
				int num16 = GloabFunc.GetOffset(float_1, num5, num7);
				int num17 = GloabFunc.GetOffset(float_1, num7, num7);
				array2[num14] = GloabFunc.Get2D(float_1, num17) + 2f * (GloabFunc.Get2D(float_1, num15) + GloabFunc.Get2D(float_1, num16));
				array2[num14 + 4] = GloabFunc.Get2D(float_1, num17 + 164) + 2f * (GloabFunc.Get2D(float_1, num15 + 4) + GloabFunc.Get2D(float_1, num16 + 4));
				array2[num14 + 8] = GloabFunc.Get2D(float_1, num17 + 328) + 2f * (GloabFunc.Get2D(float_1, num15 + 8) + GloabFunc.Get2D(float_1, num16 + 8));
				array2[num14 + 12] = GloabFunc.Get2D(float_1, num17 + 492) + 2f * (GloabFunc.Get2D(float_1, num15 + 12) + GloabFunc.Get2D(float_1, num16 + 12));
				array2[num14 + 16] = GloabFunc.Get2D(float_1, num17 + 656) + 2f * (GloabFunc.Get2D(float_1, num15 + 16) + GloabFunc.Get2D(float_1, num16 + 16));
				array2[num14 + 20] = GloabFunc.Get2D(float_1, num17 + 820) + 2f * (GloabFunc.Get2D(float_1, num15 + 20) + GloabFunc.Get2D(float_1, num16 + 20));
				array2[num14 + 24] = GloabFunc.Get2D(float_1, num17 + 984) + 2f * (GloabFunc.Get2D(float_1, num15 + 24) + GloabFunc.Get2D(float_1, num16 + 24));
				array2[num14 + 28] = GloabFunc.Get2D(float_1, num17 + 1148) + 2f * (GloabFunc.Get2D(float_1, num15 + 28) + GloabFunc.Get2D(float_1, num16 + 28));
				array2[num14 + 32] = GloabFunc.Get2D(float_1, num17 + 1312) + 2f * (GloabFunc.Get2D(float_1, num15 + 32) + GloabFunc.Get2D(float_1, num16 + 32));
				array2[num14 + 36] = GloabFunc.Get2D(float_1, num17 + 1476) + 2f * (GloabFunc.Get2D(float_1, num15 + 36) + GloabFunc.Get2D(float_1, num16 + 36));
				float num18 = -1f;
				float num19 = 1f;
				float num20 = 0f;
				int num21 = num6;
				int num22 = num7;
				num14 += num7;
				num15 = GloabFunc.GetOffset(float_1, num2, num6);
				num16 = GloabFunc.GetOffset(float_1, num5, num6);
				int num23 = GloabFunc.GetOffset(float_1, num6, num6);
				num17 = GloabFunc.GetOffset(float_1, num6, num7);
				int num24 = dnOffset + num6;
				int num25 = dnOffset + num7;
				float[] array3 = array;
				int num26 = num14 + num7;
				int num30;
				do
				{
					float num27 = num12 + float_0[num24];
					float num28 = num13 + GloabFunc.Get2D(float_1, num23) + 2f * (GloabFunc.Get2D(float_1, num15) + GloabFunc.Get2D(float_1, num16));
					array2 = array3;
					num14 = num26;
					int num29 = num25;
					num30 = num17;
					do
					{
						float num31 = num27 + float_0[num29];
						float num32 = num31 * num31;
						float num33 = num28 + array2[num14] + 2f * GloabFunc.Get2D(float_1, num30);
						if (num19 * num32 > num18 * num33)
						{
							num18 = num32;
							num20 = num31;
							num19 = num33;
							num21 = num24 - dnOffset;
							num22 = num29 - dnOffset;
						}
						num14 += 4;
						num29 += 4;
						num30 += 4;
					}
					while (num29 < num);
					num24 += 4;
					num15 += 4;
					num16 += 4;
					num23 += 164;
					num17 += 160;
				}
				while (num24 <= num);
				num6 = num21;
				num7 = num22;
				array2 = array;
				num14 = num9;
				num15 = GloabFunc.GetOffset(float_1, num2, num9);
				num16 = GloabFunc.GetOffset(float_1, num5, num9);
				num23 = GloabFunc.GetOffset(float_1, num6, num9);
				num17 = GloabFunc.GetOffset(float_1, num7, num9);
				int num34 = GloabFunc.GetOffset(float_1, num9, num9);
				array2[num14] = GloabFunc.Get2D(float_1, num34) + 2f * (GloabFunc.Get2D(float_1, num15) + GloabFunc.Get2D(float_1, num16) + GloabFunc.Get2D(float_1, num23) + GloabFunc.Get2D(float_1, num17));
				array2[num14 + 4] = GloabFunc.Get2D(float_1, num34 + 164) + 2f * (GloabFunc.Get2D(float_1, num15 + 4) + GloabFunc.Get2D(float_1, num16 + 4) + GloabFunc.Get2D(float_1, num23 + 4) + GloabFunc.Get2D(float_1, num17 + 4));
				array2[num14 + 8] = GloabFunc.Get2D(float_1, num34 + 328) + 2f * (GloabFunc.Get2D(float_1, num15 + 8) + GloabFunc.Get2D(float_1, num16 + 8) + GloabFunc.Get2D(float_1, num23 + 8) + GloabFunc.Get2D(float_1, num17 + 8));
				array2[num14 + 12] = GloabFunc.Get2D(float_1, num34 + 492) + 2f * (GloabFunc.Get2D(float_1, num15 + 12) + GloabFunc.Get2D(float_1, num16 + 12) + GloabFunc.Get2D(float_1, num23 + 12) + GloabFunc.Get2D(float_1, num17 + 12));
				array2[num14 + 16] = GloabFunc.Get2D(float_1, num34 + 656) + 2f * (GloabFunc.Get2D(float_1, num15 + 16) + GloabFunc.Get2D(float_1, num16 + 16) + GloabFunc.Get2D(float_1, num23 + 16) + GloabFunc.Get2D(float_1, num17 + 16));
				array2[num14 + 20] = GloabFunc.Get2D(float_1, num34 + 820) + 2f * (GloabFunc.Get2D(float_1, num15 + 20) + GloabFunc.Get2D(float_1, num16 + 20) + GloabFunc.Get2D(float_1, num23 + 20) + GloabFunc.Get2D(float_1, num17 + 20));
				array2[num14 + 24] = GloabFunc.Get2D(float_1, num34 + 984) + 2f * (GloabFunc.Get2D(float_1, num15 + 24) + GloabFunc.Get2D(float_1, num16 + 24) + GloabFunc.Get2D(float_1, num23 + 24) + GloabFunc.Get2D(float_1, num17 + 24));
				array2[num14 + 28] = GloabFunc.Get2D(float_1, num34 + 1148) + 2f * (GloabFunc.Get2D(float_1, num15 + 28) + GloabFunc.Get2D(float_1, num16 + 28) + GloabFunc.Get2D(float_1, num23 + 28) + GloabFunc.Get2D(float_1, num17 + 28));
				array2[num14 + 32] = GloabFunc.Get2D(float_1, num34 + 1312) + 2f * (GloabFunc.Get2D(float_1, num15 + 32) + GloabFunc.Get2D(float_1, num16 + 32) + GloabFunc.Get2D(float_1, num23 + 32) + GloabFunc.Get2D(float_1, num17 + 32));
				array2[num14 + 36] = GloabFunc.Get2D(float_1, num34 + 1476) + 2f * (GloabFunc.Get2D(float_1, num15 + 36) + GloabFunc.Get2D(float_1, num16 + 36) + GloabFunc.Get2D(float_1, num23 + 36) + GloabFunc.Get2D(float_1, num17 + 36));
				num12 = num20;
				num13 = num19;
				num18 = -1f;
				num19 = 1f;
				num20 = 0f;
				num21 = num8;
				num22 = num9;
				num24 = dnOffset + num8;
				num25 = dnOffset + num9;
				num15 = GloabFunc.GetOffset(float_1, num2, num8);
				num16 = GloabFunc.GetOffset(float_1, num5, num8);
				num23 = GloabFunc.GetOffset(float_1, num6, num8);
				num17 = GloabFunc.GetOffset(float_1, num7, num8);
				num30 = GloabFunc.GetOffset(float_1, num8, num8);
				num34 = GloabFunc.GetOffset(float_1, num8, num9);
				array3 = array;
				num26 = num9;
				int num35;
				do
				{
					float num27 = num12 + float_0[num24];
					float num28 = num13 + GloabFunc.Get2D(float_1, num30) + 2f * (GloabFunc.Get2D(float_1, num15) + GloabFunc.Get2D(float_1, num16) + GloabFunc.Get2D(float_1, num23) + GloabFunc.Get2D(float_1, num17));
					int num29 = num25;
					num35 = num34;
					array2 = array3;
					num14 = num26;
					do
					{
						float num31 = num27 + float_0[num29];
						float num32 = num31 * num31;
						float num33 = num28 + array2[num14] + 2f * GloabFunc.Get2D(float_1, num35);
						if (num19 * num32 > num18 * num33)
						{
							num18 = num32;
							num20 = num31;
							num19 = num33;
							num21 = num24 - dnOffset;
							num22 = num29 - dnOffset;
						}
						num29 += 4;
						num14 += 4;
						num35 += 4;
					}
					while (num29 <= num);
					num15 += 4;
					num16 += 4;
					num23 += 4;
					num17 += 4;
					num30 += 164;
					num34 += 160;
					num24 += 4;
				}
				while (num24 < num);
				num8 = num21;
				num9 = num22;
				array2 = array;
				num14 = num11;
				num15 = GloabFunc.GetOffset(float_1, num2, num11);
				num16 = GloabFunc.GetOffset(float_1, num5, num11);
				num23 = GloabFunc.GetOffset(float_1, num6, num11);
				num17 = GloabFunc.GetOffset(float_1, num7, num11);
				num30 = GloabFunc.GetOffset(float_1, num8, num11);
				num34 = GloabFunc.GetOffset(float_1, num9, num11);
				int num36 = GloabFunc.GetOffset(float_1, num11, num11);
				array2[num14] = GloabFunc.Get2D(float_1, num36) + 2f * (GloabFunc.Get2D(float_1, num15) + GloabFunc.Get2D(float_1, num16) + GloabFunc.Get2D(float_1, num23) + GloabFunc.Get2D(float_1, num17) + GloabFunc.Get2D(float_1, num30) + GloabFunc.Get2D(float_1, num34));
				array2[num14 + 4] = GloabFunc.Get2D(float_1, num36 + 164) + 2f * (GloabFunc.Get2D(float_1, num15 + 4) + GloabFunc.Get2D(float_1, num16 + 4) + GloabFunc.Get2D(float_1, num23 + 4) + GloabFunc.Get2D(float_1, num17 + 4) + GloabFunc.Get2D(float_1, num30 + 4) + GloabFunc.Get2D(float_1, num34 + 4));
				array2[num14 + 8] = GloabFunc.Get2D(float_1, num36 + 328) + 2f * (GloabFunc.Get2D(float_1, num15 + 8) + GloabFunc.Get2D(float_1, num16 + 8) + GloabFunc.Get2D(float_1, num23 + 8) + GloabFunc.Get2D(float_1, num17 + 8) + GloabFunc.Get2D(float_1, num30 + 8) + GloabFunc.Get2D(float_1, num34 + 8));
				array2[num14 + 12] = GloabFunc.Get2D(float_1, num36 + 492) + 2f * (GloabFunc.Get2D(float_1, num15 + 12) + GloabFunc.Get2D(float_1, num16 + 12) + GloabFunc.Get2D(float_1, num23 + 12) + GloabFunc.Get2D(float_1, num17 + 12) + GloabFunc.Get2D(float_1, num30 + 12) + GloabFunc.Get2D(float_1, num34 + 12));
				array2[num14 + 16] = GloabFunc.Get2D(float_1, num36 + 656) + 2f * (GloabFunc.Get2D(float_1, num15 + 16) + GloabFunc.Get2D(float_1, num16 + 16) + GloabFunc.Get2D(float_1, num23 + 16) + GloabFunc.Get2D(float_1, num17 + 16) + GloabFunc.Get2D(float_1, num30 + 16) + GloabFunc.Get2D(float_1, num34 + 16));
				array2[num14 + 20] = GloabFunc.Get2D(float_1, num36 + 820) + 2f * (GloabFunc.Get2D(float_1, num15 + 20) + GloabFunc.Get2D(float_1, num16 + 20) + GloabFunc.Get2D(float_1, num23 + 20) + GloabFunc.Get2D(float_1, num17 + 20) + GloabFunc.Get2D(float_1, num30 + 20) + GloabFunc.Get2D(float_1, num34 + 20));
				array2[num14 + 24] = GloabFunc.Get2D(float_1, num36 + 984) + 2f * (GloabFunc.Get2D(float_1, num15 + 24) + GloabFunc.Get2D(float_1, num16 + 24) + GloabFunc.Get2D(float_1, num23 + 24) + GloabFunc.Get2D(float_1, num17 + 24) + GloabFunc.Get2D(float_1, num30 + 24) + GloabFunc.Get2D(float_1, num34 + 24));
				array2[num14 + 28] = GloabFunc.Get2D(float_1, num36 + 1148) + 2f * (GloabFunc.Get2D(float_1, num15 + 28) + GloabFunc.Get2D(float_1, num16 + 28) + GloabFunc.Get2D(float_1, num23 + 28) + GloabFunc.Get2D(float_1, num17 + 28) + GloabFunc.Get2D(float_1, num30 + 28) + GloabFunc.Get2D(float_1, num34 + 28));
				array2[num14 + 32] = GloabFunc.Get2D(float_1, num36 + 1312) + 2f * (GloabFunc.Get2D(float_1, num15 + 32) + GloabFunc.Get2D(float_1, num16 + 32) + GloabFunc.Get2D(float_1, num23 + 32) + GloabFunc.Get2D(float_1, num17 + 32) + GloabFunc.Get2D(float_1, num30 + 32) + GloabFunc.Get2D(float_1, num34 + 32));
				array2[num14 + 36] = GloabFunc.Get2D(float_1, num36 + 1476) + 2f * (GloabFunc.Get2D(float_1, num15 + 36) + GloabFunc.Get2D(float_1, num16 + 36) + GloabFunc.Get2D(float_1, num23 + 36) + GloabFunc.Get2D(float_1, num17 + 36) + GloabFunc.Get2D(float_1, num30 + 36) + GloabFunc.Get2D(float_1, num34 + 36));
				num12 = num20;
				num13 = num19;
				num18 = -1f;
				num19 = 1f;
				num21 = num10;
				num22 = num11;
				num24 = dnOffset + num10;
				num25 = dnOffset + num11;
				num15 = GloabFunc.GetOffset(float_1, num2, num10);
				num16 = GloabFunc.GetOffset(float_1, num5, num10);
				num23 = GloabFunc.GetOffset(float_1, num6, num10);
				num17 = GloabFunc.GetOffset(float_1, num7, num10);
				num30 = GloabFunc.GetOffset(float_1, num8, num10);
				num34 = GloabFunc.GetOffset(float_1, num9, num10);
				num35 = GloabFunc.GetOffset(float_1, num10, num10);
				num36 = GloabFunc.GetOffset(float_1, num10, num11);
				array3 = array;
				num26 = num11;
				do
				{
					float num27 = num12 + float_0[num24];
					float num28 = num13 + GloabFunc.Get2D(float_1, num35) + 2f * (GloabFunc.Get2D(float_1, num15) + GloabFunc.Get2D(float_1, num16) + GloabFunc.Get2D(float_1, num23) + GloabFunc.Get2D(float_1, num17) + GloabFunc.Get2D(float_1, num30) + GloabFunc.Get2D(float_1, num34));
					int num29 = num25;
					int num37 = num36;
					array2 = array3;
					num14 = num26;
					do
					{
						float num31 = num27 + float_0[num29];
						float num32 = num31 * num31;
						float num33 = num28 + array2[num14] + 2f * GloabFunc.Get2D(float_1, num37);
						if (num19 * num32 > num18 * num33)
						{
							num18 = num32;
							num19 = num33;
							num21 = num24 - dnOffset;
							num22 = num29 - dnOffset;
						}
						num29 += 4;
						num14 += 4;
						num37 += 4;
					}
					while (num29 <= num);
					num15 += 4;
					num16 += 4;
					num23 += 4;
					num17 += 4;
					num30 += 4;
					num34 += 4;
					num35 += 164;
					num36 += 160;
					num24 += 4;
				}
				while (num24 < num);
				if (num4 * num18 > num3 * num19)
				{
					num3 = num18;
					num4 = num19;
					codvec[codvecOffset] = (int)((short)num2);
					codvec[codvecOffset + 1] = (int)((short)num5);
					codvec[codvecOffset + 2] = (int)((short)num6);
					codvec[codvecOffset + 3] = (int)((short)num7);
					codvec[codvecOffset + 4] = (int)((short)num8);
					codvec[codvecOffset + 5] = (int)((short)num9);
					codvec[codvecOffset + 6] = (int)((short)num21);
					codvec[codvecOffset + 7] = (int)((short)num22);
				}
				int num38 = ipos[iposOffset + 1];
				int num39 = 1;
				for (int j = 2; j < 8; j++)
				{
					ipos[iposOffset + num39] = ipos[iposOffset + j];
					num39++;
				}
				ipos[iposOffset + 7] = num38;
			}
		}
		private static void build_code_8i40_31bits(int[] codvec, int codvecOffset, float[] dn_sign, int dn_signOffset, float[] float_0, int codOffset, float[] float_1, int hOffset, float[] float_2, int yOffset, int[] sign_indx, int sign_indxOffset, int[] pos_indx, int pos_indxOffset)
		{
			int[] array = new int[8];
			GloabFunc.memsetFloat(float_0, codOffset, 0f, 160);
			for (int i = 0; i < 4; i++)
			{
				pos_indx[pos_indxOffset + i] = -1;
				sign_indx[sign_indxOffset + i] = -1;
			}
			for (int j = 0; j < 8; j++)
			{
				int i = codvec[codvecOffset + j];
				int num = (int)dn_sign[dn_signOffset + i];
				int num2 = i >> 2;
				int num3 = i & 3;
				int num4;
				if (num > 0)
				{
					float_0[codOffset + i] = float_0[codOffset + i] + 0.9998779f;
					array[j] = 1;
					num4 = 0;
				}
				else
				{
					float_0[codOffset + i] = float_0[codOffset + i] - 0.9998779f;
					array[j] = -1;
					num4 = 1;
				}
				if (pos_indx[pos_indxOffset + num3] < 0)
				{
					pos_indx[pos_indxOffset + num3] = num2;
					sign_indx[sign_indxOffset + num3] = num4;
				}
				else
				{
					if (((num4 ^ sign_indx[sign_indxOffset + num3]) & 1) == 0)
					{
						if (pos_indx[pos_indxOffset + num3] <= num2)
						{
							pos_indx[pos_indxOffset + num3 + 4] = num2;
						}
						else
						{
							pos_indx[pos_indxOffset + num3 + 4] = pos_indx[pos_indxOffset + num3];
							pos_indx[pos_indxOffset + num3] = num2;
							sign_indx[sign_indxOffset + num3] = num4;
						}
					}
					else
					{
						if (pos_indx[pos_indxOffset + num3] <= num2)
						{
							pos_indx[pos_indxOffset + num3 + 4] = pos_indx[pos_indxOffset + num3];
							pos_indx[pos_indxOffset + num3] = num2;
							sign_indx[sign_indxOffset + num3] = num4;
						}
						else
						{
							pos_indx[pos_indxOffset + num3 + 4] = num2;
						}
					}
				}
			}
			int num5 = hOffset - codvec[codvecOffset];
			int num6 = hOffset - codvec[codvecOffset + 1];
			int num7 = hOffset - codvec[codvecOffset + 2];
			int num8 = hOffset - codvec[codvecOffset + 3];
			int num9 = hOffset - codvec[codvecOffset + 4];
			int num10 = hOffset - codvec[codvecOffset + 5];
			int num11 = hOffset - codvec[codvecOffset + 6];
			int num12 = hOffset - codvec[codvecOffset + 7];
			for (int i = 0; i < 40; i++)
			{
				double num13 = (double)(float_1[num5++] * (float)array[0]);
				num13 += (double)(float_1[num6++] * (float)array[1]);
				num13 += (double)(float_1[num7++] * (float)array[2]);
				num13 += (double)(float_1[num8++] * (float)array[3]);
				num13 += (double)(float_1[num9++] * (float)array[4]);
				num13 += (double)(float_1[num10++] * (float)array[5]);
				num13 += (double)(float_1[num11++] * (float)array[6]);
				num13 += (double)(float_1[num12++] * (float)array[7]);
				float_2[yOffset + i] = (float)num13;
			}
		}
		private static short compress10(int pos_indxA, int pos_indxB, int pos_indxC)
		{
			int num = pos_indxA >> 1;
			int num2 = (pos_indxB >> 1) * 5;
			int num3 = (pos_indxC >> 1) * 25;
			int num4 = num + (num2 + num3) << 3;
			num = (pos_indxA & 1);
			num2 = (pos_indxB & 1) << 1;
			num3 = (pos_indxC & 1) << 2;
			num4 += num + (num2 + num3);
			return (short)num4;
		}
		private static void compress_code(int[] sign_indx, int sign_indxOffset, int[] pos_indx, int pos_indxOffset, short[] indx, int indxOffset)
		{
			for (int i = 0; i < 4; i++)
			{
				indx[indxOffset + i] = (short)sign_indx[sign_indxOffset + i];
			}
			indx[indxOffset + 4] = GloabFunc.compress10(pos_indx[pos_indxOffset], pos_indx[pos_indxOffset + 4], pos_indx[pos_indxOffset + 1]);
			indx[indxOffset + 4 + 1] = GloabFunc.compress10(pos_indx[pos_indxOffset + 2], pos_indx[pos_indxOffset + 6], pos_indx[pos_indxOffset + 5]);
			int num = pos_indx[pos_indxOffset + 7] >> 1 & 1;
			int num2;
			if (num == 1)
			{
				num2 = 4 - (pos_indx[pos_indxOffset + 3] >> 1);
			}
			else
			{
				num2 = pos_indx[pos_indxOffset + 3] >> 1;
			}
			num = (pos_indx[pos_indxOffset + 7] >> 1) * 5;
			num = (num2 + num << 5) + 12;
			int num3 = num * 1311 >> 15 << 2;
			num2 = (pos_indx[pos_indxOffset + 3] & 1);
			num = (pos_indx[pos_indxOffset + 7] & 1) << 1;
			indx[indxOffset + 4 + 2] = (short)(num2 + (num + num3));
		}
		private static void code_8i40_31bits(float[] float_0, int xOffset, float[] float_1, int cnOffset, float[] float_2, int hOffset, int T0, float pitch_sharp, float[] code, int codeOffset, float[] float_3, int yOffset, short[] anap, int anapOffset)
		{
			float[,] float_4 = new float[40, 40];
			float[] array = new float[40];
			float[] array2 = new float[40];
			int[] ipos = new int[8];
			int[] pos_max = new int[4];
			int[] codvec = new int[8];
			int[] sign_indx = new int[4];
			int[] pos_indx = new int[8];
			if (pitch_sharp > 1f)
			{
				pitch_sharp = 1f;
			}
			if (pitch_sharp != 0f)
			{
				for (int i = T0; i < 40; i++)
				{
					float_2[hOffset + i] += float_2[hOffset + i - T0] * pitch_sharp;
				}
			}
			GloabFunc.cor_h_x(float_2, hOffset, float_0, xOffset, array, 0);
			GloabFunc.set_sign12k2(array, 0, float_1, cnOffset, array2, 0, pos_max, 0, 4, ipos, 0, 4);
			GloabFunc.cor_h(float_2, hOffset, array2, 0, float_4);
			GloabFunc.search_8i40(array, 0, float_4, ipos, 0, pos_max, 0, codvec, 0);
			GloabFunc.build_code_8i40_31bits(codvec, 0, array2, 0, code, codeOffset, float_2, hOffset, float_3, yOffset, sign_indx, 0, pos_indx, 0);
			GloabFunc.compress_code(sign_indx, 0, pos_indx, 0, anap, anapOffset);
			if (pitch_sharp != 0f)
			{
				for (int i = T0; i < 40; i++)
				{
					code[codeOffset + i] += code[codeOffset + i - T0] * pitch_sharp;
				}
			}
		}
		private static void search_10i40(float[] float_0, int dnOffset, float[,] float_1, int[] ipos, int iposOffset, int[] pos_max, int pos_maxOffset, int[] codvec, int codvecOffset)
		{
			float[] array = new float[40];
			int num = 0;
			int num2 = 0;
			int num3 = dnOffset + 39;
			int num4 = pos_max[pos_maxOffset + ipos[iposOffset]];
			float num5 = -1f;
			float num6 = 1f;
			for (int i = 0; i < 10; i++)
			{
				codvec[codvecOffset + i] = i;
			}
			int offset = GloabFunc.GetOffset(float_1, num4, num4);
			for (int i = 1; i < 5; i++)
			{
				int num7 = pos_max[pos_maxOffset + ipos[iposOffset + 1]];
				int num8 = ipos[iposOffset + 2];
				int num9 = ipos[iposOffset + 3];
				int num10 = ipos[iposOffset + 4];
				int num11 = ipos[iposOffset + 5];
				int num12 = ipos[iposOffset + 6];
				int num13 = ipos[iposOffset + 7];
				int num14 = ipos[iposOffset + 8];
				int num15 = ipos[iposOffset + 9];
				float num16 = float_0[dnOffset + num4] + float_0[dnOffset + num7];
				float num17 = GloabFunc.Get2D(float_1, offset) + float_1[num7, num7] + 2f * float_1[num4, num7];
				float[] array2 = array;
				int num18 = num9;
				int num19 = GloabFunc.GetOffset(float_1, num4, num9);
				int num20 = GloabFunc.GetOffset(float_1, num7, num9);
				int num21 = GloabFunc.GetOffset(float_1, num9, num9);
				array2[num18] = GloabFunc.Get2D(float_1, num21) + 2f * (GloabFunc.Get2D(float_1, num19) + GloabFunc.Get2D(float_1, num20));
				array2[num18 + 5] = GloabFunc.Get2D(float_1, num21 + 205) + 2f * (GloabFunc.Get2D(float_1, num19 + 5) + GloabFunc.Get2D(float_1, num20 + 5));
				array2[num18 + 10] = GloabFunc.Get2D(float_1, num21 + 410) + 2f * (GloabFunc.Get2D(float_1, num19 + 10) + GloabFunc.Get2D(float_1, num20 + 10));
				array2[num18 + 15] = GloabFunc.Get2D(float_1, num21 + 615) + 2f * (GloabFunc.Get2D(float_1, num19 + 15) + GloabFunc.Get2D(float_1, num20 + 15));
				array2[num18 + 20] = GloabFunc.Get2D(float_1, num21 + 820) + 2f * (GloabFunc.Get2D(float_1, num19 + 20) + GloabFunc.Get2D(float_1, num20 + 20));
				array2[num18 + 25] = GloabFunc.Get2D(float_1, num21 + 1025) + 2f * (GloabFunc.Get2D(float_1, num19 + 25) + GloabFunc.Get2D(float_1, num20 + 25));
				array2[num18 + 30] = GloabFunc.Get2D(float_1, num21 + 1230) + 2f * (GloabFunc.Get2D(float_1, num19 + 30) + GloabFunc.Get2D(float_1, num20 + 30));
				array2[num18 + 35] = GloabFunc.Get2D(float_1, num21 + 1435) + 2f * (GloabFunc.Get2D(float_1, num19 + 35) + GloabFunc.Get2D(float_1, num20 + 35));
				float num22 = -1f;
				float num23 = 1f;
				float num24 = 0f;
				int num25 = num8;
				int num26 = num9;
				num19 = GloabFunc.GetOffset(float_1, num4, num8);
				num20 = GloabFunc.GetOffset(float_1, num7, num8);
				int num27 = GloabFunc.GetOffset(float_1, num8, num8);
				num21 = GloabFunc.GetOffset(float_1, num8, num9);
				int num28 = dnOffset + num8;
				int num29 = dnOffset + num9;
				float[] array3 = array;
				int num30 = num9;
				int num33;
				int num34;
				do
				{
					float num31 = num16 + float_0[num28];
					float num32 = num17 + GloabFunc.Get2D(float_1, num27) + 2f * (GloabFunc.Get2D(float_1, num19) + GloabFunc.Get2D(float_1, num20));
					array2 = array3;
					num18 = num30;
					num33 = num29;
					num34 = num21;
					do
					{
						float num35 = num31 + float_0[num33];
						float num36 = num35 * num35;
						float num37 = num32 + array2[num18] + 2f * GloabFunc.Get2D(float_1, num34);
						if (num23 * num36 > num22 * num37)
						{
							num22 = num36;
							num24 = num35;
							num23 = num37;
							num25 = (int)((short)(num28 - dnOffset));
							num26 = (int)((short)(num33 - dnOffset));
						}
						num18 += 5;
						num33 += 5;
						num34 += 5;
					}
					while (num33 < num3);
					num28 += 5;
					num19 += 5;
					num20 += 5;
					num27 += 205;
					num21 += 200;
				}
				while (num28 <= num3);
				num8 = num25;
				num9 = num26;
				array2 = array;
				num18 = num11;
				num19 = GloabFunc.GetOffset(float_1, num4, num11);
				num20 = GloabFunc.GetOffset(float_1, num7, num11);
				num27 = GloabFunc.GetOffset(float_1, num8, num11);
				num21 = GloabFunc.GetOffset(float_1, num9, num11);
				int num38 = GloabFunc.GetOffset(float_1, num11, num11);
				array2[num18] = GloabFunc.Get2D(float_1, num38) + 2f * (GloabFunc.Get2D(float_1, num19) + GloabFunc.Get2D(float_1, num20) + GloabFunc.Get2D(float_1, num27) + GloabFunc.Get2D(float_1, num21));
				array2[num18 + 5] = GloabFunc.Get2D(float_1, num38 + 205) + 2f * (GloabFunc.Get2D(float_1, num19 + 5) + GloabFunc.Get2D(float_1, num20 + 5) + GloabFunc.Get2D(float_1, num27 + 5) + GloabFunc.Get2D(float_1, num21 + 5));
				array2[num18 + 10] = GloabFunc.Get2D(float_1, num38 + 410) + 2f * (GloabFunc.Get2D(float_1, num19 + 10) + GloabFunc.Get2D(float_1, num20 + 10) + GloabFunc.Get2D(float_1, num27 + 10) + GloabFunc.Get2D(float_1, num21 + 10));
				array2[num18 + 15] = GloabFunc.Get2D(float_1, num38 + 615) + 2f * (GloabFunc.Get2D(float_1, num19 + 15) + GloabFunc.Get2D(float_1, num20 + 15) + GloabFunc.Get2D(float_1, num27 + 15) + GloabFunc.Get2D(float_1, num21 + 15));
				array2[num18 + 20] = GloabFunc.Get2D(float_1, num38 + 820) + 2f * (GloabFunc.Get2D(float_1, num19 + 20) + GloabFunc.Get2D(float_1, num20 + 20) + GloabFunc.Get2D(float_1, num27 + 20) + GloabFunc.Get2D(float_1, num21 + 20));
				array2[num18 + 25] = GloabFunc.Get2D(float_1, num38 + 1025) + 2f * (GloabFunc.Get2D(float_1, num19 + 25) + GloabFunc.Get2D(float_1, num20 + 25) + GloabFunc.Get2D(float_1, num27 + 25) + GloabFunc.Get2D(float_1, num21 + 25));
				array2[num18 + 30] = GloabFunc.Get2D(float_1, num38 + 1230) + 2f * (GloabFunc.Get2D(float_1, num19 + 30) + GloabFunc.Get2D(float_1, num20 + 30) + GloabFunc.Get2D(float_1, num27 + 30) + GloabFunc.Get2D(float_1, num21 + 30));
				array2[num18 + 35] = GloabFunc.Get2D(float_1, num38 + 1435) + 2f * (GloabFunc.Get2D(float_1, num19 + 35) + GloabFunc.Get2D(float_1, num20 + 35) + GloabFunc.Get2D(float_1, num27 + 35) + GloabFunc.Get2D(float_1, num21 + 35));
				num16 = num24;
				num17 = num23;
				num22 = -1f;
				num23 = 1f;
				num24 = 0f;
				num25 = num10;
				num26 = num11;
				num28 = dnOffset + num10;
				num29 = dnOffset + num11;
				num19 = GloabFunc.GetOffset(float_1, num4, num10);
				num20 = GloabFunc.GetOffset(float_1, num7, num10);
				num27 = GloabFunc.GetOffset(float_1, num8, num10);
				num21 = GloabFunc.GetOffset(float_1, num9, num10);
				num34 = GloabFunc.GetOffset(float_1, num10, num10);
				num38 = GloabFunc.GetOffset(float_1, num10, num11);
				array3 = array;
				num30 = num11;
				int num39;
				do
				{
					float num31 = num16 + float_0[num28];
					float num32 = num17 + GloabFunc.Get2D(float_1, num34) + 2f * (GloabFunc.Get2D(float_1, num19) + GloabFunc.Get2D(float_1, num20) + GloabFunc.Get2D(float_1, num27) + GloabFunc.Get2D(float_1, num21));
					num33 = num29;
					num39 = num38;
					array2 = array3;
					num18 = num30;
					do
					{
						float num35 = num31 + float_0[num33];
						float num36 = num35 * num35;
						float num37 = num32 + array2[num18] + 2f * GloabFunc.Get2D(float_1, num39);
						if (num23 * num36 > num22 * num37)
						{
							num22 = num36;
							num24 = num35;
							num23 = num37;
							num25 = (int)((short)(num28 - dnOffset));
							num26 = (int)((short)(num33 - dnOffset));
						}
						num33 += 5;
						num18 += 5;
						num39 += 5;
					}
					while (num33 <= num3);
					num19 += 5;
					num20 += 5;
					num27 += 5;
					num21 += 5;
					num34 += 205;
					num38 += 200;
					num28 += 5;
				}
				while (num28 < num3);
				num10 = num25;
				num11 = num26;
				array2 = array;
				num18 = num13;
				num27 = GloabFunc.GetOffset(float_1, num4, num13);
				num20 = GloabFunc.GetOffset(float_1, num7, num13);
				num27 = GloabFunc.GetOffset(float_1, num8, num13);
				num21 = GloabFunc.GetOffset(float_1, num9, num13);
				num34 = GloabFunc.GetOffset(float_1, num10, num13);
				num38 = GloabFunc.GetOffset(float_1, num11, num13);
				int num40 = GloabFunc.GetOffset(float_1, num13, num13);
				array2[num18] = GloabFunc.Get2D(float_1, num40) + 2f * (GloabFunc.Get2D(float_1, num19) + GloabFunc.Get2D(float_1, num20) + GloabFunc.Get2D(float_1, num27) + GloabFunc.Get2D(float_1, num21) + GloabFunc.Get2D(float_1, num34) + GloabFunc.Get2D(float_1, num38));
				array2[num18 + 5] = GloabFunc.Get2D(float_1, num40 + 205) + 2f * (GloabFunc.Get2D(float_1, num19 + 5) + GloabFunc.Get2D(float_1, num20 + 5) + GloabFunc.Get2D(float_1, num27 + 5) + GloabFunc.Get2D(float_1, num21 + 5) + GloabFunc.Get2D(float_1, num34 + 5) + GloabFunc.Get2D(float_1, num38 + 5));
				array2[num18 + 10] = GloabFunc.Get2D(float_1, num40 + 410) + 2f * (GloabFunc.Get2D(float_1, num19 + 10) + GloabFunc.Get2D(float_1, num20 + 10) + GloabFunc.Get2D(float_1, num27 + 10) + GloabFunc.Get2D(float_1, num21 + 10) + GloabFunc.Get2D(float_1, num34 + 10) + GloabFunc.Get2D(float_1, num38 + 10));
				array2[num18 + 15] = GloabFunc.Get2D(float_1, num40 + 615) + 2f * (GloabFunc.Get2D(float_1, num19 + 15) + GloabFunc.Get2D(float_1, num20 + 15) + GloabFunc.Get2D(float_1, num27 + 15) + GloabFunc.Get2D(float_1, num21 + 15) + GloabFunc.Get2D(float_1, num34 + 15) + GloabFunc.Get2D(float_1, num38 + 15));
				array2[num18 + 20] = GloabFunc.Get2D(float_1, num40 + 820) + 2f * (GloabFunc.Get2D(float_1, num19 + 20) + GloabFunc.Get2D(float_1, num20 + 20) + GloabFunc.Get2D(float_1, num27 + 20) + GloabFunc.Get2D(float_1, num21 + 20) + GloabFunc.Get2D(float_1, num34 + 20) + GloabFunc.Get2D(float_1, num38 + 20));
				array2[num18 + 25] = GloabFunc.Get2D(float_1, num40 + 1025) + 2f * (GloabFunc.Get2D(float_1, num19 + 25) + GloabFunc.Get2D(float_1, num20 + 25) + GloabFunc.Get2D(float_1, num27 + 25) + GloabFunc.Get2D(float_1, num21 + 25) + GloabFunc.Get2D(float_1, num34 + 25) + GloabFunc.Get2D(float_1, num38 + 25));
				array2[num18 + 30] = GloabFunc.Get2D(float_1, num40 + 1230) + 2f * (GloabFunc.Get2D(float_1, num19 + 30) + GloabFunc.Get2D(float_1, num20 + 30) + GloabFunc.Get2D(float_1, num27 + 30) + GloabFunc.Get2D(float_1, num21 + 30) + GloabFunc.Get2D(float_1, num34 + 30) + GloabFunc.Get2D(float_1, num38 + 30));
				array2[num18 + 35] = GloabFunc.Get2D(float_1, num40 + 1435) + 2f * (GloabFunc.Get2D(float_1, num19 + 35) + GloabFunc.Get2D(float_1, num20 + 35) + GloabFunc.Get2D(float_1, num27 + 35) + GloabFunc.Get2D(float_1, num21 + 35) + GloabFunc.Get2D(float_1, num34 + 35) + GloabFunc.Get2D(float_1, num38 + 35));
				num16 = num24;
				num17 = num23;
				num22 = -1f;
				num23 = 1f;
				num24 = 0f;
				num25 = num12;
				num26 = num13;
				num28 = dnOffset + num12;
				num29 = dnOffset + num13;
				num19 = GloabFunc.GetOffset(float_1, num4, num12);
				num20 = GloabFunc.GetOffset(float_1, num7, num12);
				num27 = GloabFunc.GetOffset(float_1, num8, num12);
				num21 = GloabFunc.GetOffset(float_1, num9, num12);
				num34 = GloabFunc.GetOffset(float_1, num10, num12);
				num38 = GloabFunc.GetOffset(float_1, num11, num12);
				num39 = GloabFunc.GetOffset(float_1, num12, num12);
				num40 = GloabFunc.GetOffset(float_1, num12, num13);
				array3 = array;
				num30 = num13;
				do
				{
					float num31 = num16 + float_0[num28];
					float num32 = num17 + GloabFunc.Get2D(float_1, num39) + 2f * (GloabFunc.Get2D(float_1, num19) + GloabFunc.Get2D(float_1, num20) + GloabFunc.Get2D(float_1, num27) + GloabFunc.Get2D(float_1, num21) + GloabFunc.Get2D(float_1, num34) + GloabFunc.Get2D(float_1, num38));
					array2 = array3;
					num18 = num30;
					do
					{
						float num35 = num31 + float_0[num33];
						float num36 = num35 * num35;
						float num37 = num32 + array2[num18] + 2f * GloabFunc.Get2D(float_1, num);
						if (num23 * num36 > num22 * num37)
						{
							num22 = num36;
							num24 = num35;
							num23 = num37;
							num25 = (int)((short)(num28 - dnOffset));
							num26 = (int)((short)(num33 - dnOffset));
						}
						num33 += 5;
						num18 += 5;
						num += 5;
					}
					while (num33 <= num3);
					num19 += 5;
					num20 += 5;
					num27 += 5;
					num21 += 5;
					num34 += 5;
					num38 += 5;
					num39 += 205;
					num40 += 200;
					num28 += 5;
				}
				while (num28 < num3);
				num12 = num25;
				num13 = num26;
				array2 = array;
				num18 = num15;
				num19 = GloabFunc.GetOffset(float_1, num4, num15);
				num20 = GloabFunc.GetOffset(float_1, num7, num15);
				num27 = GloabFunc.GetOffset(float_1, num8, num15);
				num21 = GloabFunc.GetOffset(float_1, num9, num15);
				num34 = GloabFunc.GetOffset(float_1, num10, num15);
				num38 = GloabFunc.GetOffset(float_1, num11, num15);
				num39 = GloabFunc.GetOffset(float_1, num12, num15);
				num40 = GloabFunc.GetOffset(float_1, num13, num15);
				int num41 = GloabFunc.GetOffset(float_1, num15, num15);
				array2[num18] = GloabFunc.Get2D(float_1, num41) + 2f * (GloabFunc.Get2D(float_1, num19) + GloabFunc.Get2D(float_1, num20) + GloabFunc.Get2D(float_1, num27) + GloabFunc.Get2D(float_1, num21) + GloabFunc.Get2D(float_1, num34) + GloabFunc.Get2D(float_1, num38) + GloabFunc.Get2D(float_1, num39) + GloabFunc.Get2D(float_1, num40));
				array2[num18 + 5] = GloabFunc.Get2D(float_1, num41 + 205) + 2f * (GloabFunc.Get2D(float_1, num19 + 5) + GloabFunc.Get2D(float_1, num20 + 5) + GloabFunc.Get2D(float_1, num27 + 5) + GloabFunc.Get2D(float_1, num21 + 5) + GloabFunc.Get2D(float_1, num34 + 5) + GloabFunc.Get2D(float_1, num38 + 5) + GloabFunc.Get2D(float_1, num39 + 5) + GloabFunc.Get2D(float_1, num40 + 5));
				array2[num18 + 10] = GloabFunc.Get2D(float_1, num41 + 410) + 2f * (GloabFunc.Get2D(float_1, num19 + 10) + GloabFunc.Get2D(float_1, num20 + 10) + GloabFunc.Get2D(float_1, num27 + 10) + GloabFunc.Get2D(float_1, num21 + 10) + GloabFunc.Get2D(float_1, num34 + 10) + GloabFunc.Get2D(float_1, num38 + 10) + GloabFunc.Get2D(float_1, num39 + 10) + GloabFunc.Get2D(float_1, num40 + 10));
				array2[num18 + 15] = GloabFunc.Get2D(float_1, num41 + 615) + 2f * (GloabFunc.Get2D(float_1, num19 + 15) + GloabFunc.Get2D(float_1, num20 + 15) + GloabFunc.Get2D(float_1, num27 + 15) + GloabFunc.Get2D(float_1, num21 + 15) + GloabFunc.Get2D(float_1, num34 + 15) + GloabFunc.Get2D(float_1, num38 + 15) + GloabFunc.Get2D(float_1, num39 + 15) + GloabFunc.Get2D(float_1, num40 + 15));
				array2[num18 + 20] = GloabFunc.Get2D(float_1, num41 + 820) + 2f * (GloabFunc.Get2D(float_1, num19 + 20) + GloabFunc.Get2D(float_1, num20 + 20) + GloabFunc.Get2D(float_1, num27 + 20) + GloabFunc.Get2D(float_1, num21 + 20) + GloabFunc.Get2D(float_1, num34 + 20) + GloabFunc.Get2D(float_1, num38 + 20) + GloabFunc.Get2D(float_1, num39 + 20) + GloabFunc.Get2D(float_1, num40 + 20));
				array2[num18 + 25] = GloabFunc.Get2D(float_1, num41 + 1025) + 2f * (GloabFunc.Get2D(float_1, num19 + 25) + GloabFunc.Get2D(float_1, num20 + 25) + GloabFunc.Get2D(float_1, num27 + 25) + GloabFunc.Get2D(float_1, num21 + 25) + GloabFunc.Get2D(float_1, num34 + 25) + GloabFunc.Get2D(float_1, num38 + 25) + GloabFunc.Get2D(float_1, num39 + 25) + GloabFunc.Get2D(float_1, num40 + 25));
				array2[num18 + 30] = GloabFunc.Get2D(float_1, num41 + 1230) + 2f * (GloabFunc.Get2D(float_1, num19 + 30) + GloabFunc.Get2D(float_1, num20 + 30) + GloabFunc.Get2D(float_1, num27 + 30) + GloabFunc.Get2D(float_1, num21 + 30) + GloabFunc.Get2D(float_1, num34 + 30) + GloabFunc.Get2D(float_1, num38 + 30) + GloabFunc.Get2D(float_1, num39 + 30) + GloabFunc.Get2D(float_1, num40 + 30));
				array2[num18 + 35] = GloabFunc.Get2D(float_1, num41 + 1435) + 2f * (GloabFunc.Get2D(float_1, num19 + 35) + GloabFunc.Get2D(float_1, num20 + 35) + GloabFunc.Get2D(float_1, num27 + 35) + GloabFunc.Get2D(float_1, num21 + 35) + GloabFunc.Get2D(float_1, num34 + 35) + GloabFunc.Get2D(float_1, num38 + 35) + GloabFunc.Get2D(float_1, num39 + 35) + GloabFunc.Get2D(float_1, num40 + 35));
				num16 = num24;
				num17 = num23;
				num22 = -1f;
				num23 = 1f;
				num25 = num14;
				num26 = num15;
				num28 = dnOffset + num14;
				num29 = dnOffset + num15;
				num19 = GloabFunc.GetOffset(float_1, num4, num14);
				num20 = GloabFunc.GetOffset(float_1, num7, num14);
				num27 = GloabFunc.GetOffset(float_1, num8, num14);
				num21 = GloabFunc.GetOffset(float_1, num9, num14);
				num34 = GloabFunc.GetOffset(float_1, num10, num14);
				num38 = GloabFunc.GetOffset(float_1, num11, num14);
				num39 = GloabFunc.GetOffset(float_1, num12, num14);
				num40 = GloabFunc.GetOffset(float_1, num13, num14);
				num = GloabFunc.GetOffset(float_1, num14, num14);
				num41 = GloabFunc.GetOffset(float_1, num14, num15);
				array3 = array;
				num30 = num15;
				do
				{
					float num31 = num16 + float_0[num28];
					float num32 = num17 + GloabFunc.Get2D(float_1, num) + 2f * (GloabFunc.Get2D(float_1, num19) + GloabFunc.Get2D(float_1, num20) + GloabFunc.Get2D(float_1, num27) + GloabFunc.Get2D(float_1, num21) + GloabFunc.Get2D(float_1, num34) + GloabFunc.Get2D(float_1, num38) + GloabFunc.Get2D(float_1, num39) + GloabFunc.Get2D(float_1, num40));
					array2 = array3;
					num18 = num30;
					do
					{
						float num35 = num31 + float_0[num33];
						float num36 = num35 * num35;
						float num37 = num32 + array2[num18] + 2f * GloabFunc.Get2D(float_1, num2);
						if (num23 * num36 > num22 * num37)
						{
							num22 = num36;
							num23 = num37;
							num25 = (int)((short)(num28 - dnOffset));
							num26 = (int)((short)(num33 - dnOffset));
						}
						num33 += 5;
						num18 += 5;
						num2 += 5;
					}
					while (num33 <= num3);
					num19 += 5;
					num20 += 5;
					num27 += 5;
					num21 += 5;
					num34 += 5;
					num38 += 5;
					num39 += 5;
					num40 += 5;
					num += 205;
					num41 += 200;
					num28 += 5;
				}
				while (num28 < num3);
				if (num6 * num22 > num5 * num23)
				{
					num5 = num22;
					num6 = num23;
					codvec[codvecOffset] = (int)((short)num4);
					codvec[codvecOffset + 1] = (int)((short)num7);
					codvec[codvecOffset + 2] = (int)((short)num8);
					codvec[codvecOffset + 3] = (int)((short)num9);
					codvec[codvecOffset + 4] = (int)((short)num10);
					codvec[codvecOffset + 5] = (int)((short)num11);
					codvec[codvecOffset + 6] = (int)((short)num12);
					codvec[codvecOffset + 7] = (int)((short)num13);
					codvec[codvecOffset + 8] = (int)((short)num25);
					codvec[codvecOffset + 9] = (int)((short)num26);
				}
				int num42 = ipos[iposOffset + 1];
				int num43 = 1;
				for (int j = 2; j < 10; j++)
				{
					ipos[iposOffset + num43] = ipos[iposOffset + j];
					num43++;
				}
				ipos[iposOffset + 9] = num42;
			}
		}
		private static void build_code_10i40_35bits(int[] codvec, int codvecOffset, float[] dn_sign, int dn_signOffset, float[] float_0, int codOffset, float[] float_1, int hOffset, float[] float_2, int yOffset, short[] indx, int indxOffset)
		{
			int[] array = new int[10];
			GloabFunc.memsetFloat(float_0, codOffset, 0f, 160);
			GloabFunc.memsetFloat(float_2, yOffset, 0f, 160);
			for (int i = 0; i < 5; i++)
			{
				indx[indxOffset + i] = -1;
			}
			for (int j = 0; j < 10; j++)
			{
				int i = codvec[codvecOffset + j];
				int num = (int)((short)dn_sign[dn_signOffset + i]);
				int num2 = (int)((short)(i / 5));
				int num3 = (int)((short)(i % 5));
				if (num > 0)
				{
					float_0[codOffset + i] = float_0[codOffset + i] + 1f;
					array[j] = 1;
				}
				else
				{
					float_0[codOffset + i] = float_0[codOffset + i] - 1f;
					array[j] = -1;
					num2 += 8;
				}
				if (indx[indxOffset + num3] < 0)
				{
					indx[indxOffset + num3] = (short)num2;
				}
				else
				{
					if (((num2 ^ (int)indx[indxOffset + num3]) & 8) == 0)
					{
						if ((int)indx[indxOffset + num3] <= num2)
						{
							indx[indxOffset + num3 + 5] = (short)num2;
						}
						else
						{
							indx[indxOffset + num3 + 5] = indx[indxOffset + num3];
							indx[indxOffset + num3] = (short)num2;
						}
					}
					else
					{
						if ((int)(indx[indxOffset + num3] & 7) <= (num2 & 7))
						{
							indx[indxOffset + num3 + 5] = indx[indxOffset + num3];
							indx[indxOffset + num3] = (short)num2;
						}
						else
						{
							indx[indxOffset + num3 + 5] = (short)num2;
						}
					}
				}
			}
			int num4 = hOffset - codvec[codvecOffset];
			int num5 = hOffset - codvec[codvecOffset + 1];
			int num6 = hOffset - codvec[codvecOffset + 2];
			int num7 = hOffset - codvec[codvecOffset + 3];
			int num8 = hOffset - codvec[codvecOffset + 4];
			int num9 = hOffset - codvec[codvecOffset + 5];
			int num10 = hOffset - codvec[codvecOffset + 6];
			int num11 = hOffset - codvec[codvecOffset + 7];
			int num12 = hOffset - codvec[codvecOffset + 8];
			int num13 = hOffset - codvec[codvecOffset + 9];
			for (int i = 0; i < 40; i++)
			{
				double num14 = (double)(float_1[num4++] * (float)array[0]);
				num14 += (double)(float_1[num5++] * (float)array[1]);
				num14 += (double)(float_1[num6++] * (float)array[2]);
				num14 += (double)(float_1[num7++] * (float)array[3]);
				num14 += (double)(float_1[num8++] * (float)array[4]);
				num14 += (double)(float_1[num9++] * (float)array[5]);
				num14 += (double)(float_1[num10++] * (float)array[6]);
				num14 += (double)(float_1[num11++] * (float)array[7]);
				num14 += (double)(float_1[num12++] * (float)array[8]);
				num14 += (double)(float_1[num13++] * (float)array[9]);
				float_2[yOffset + i] = (float)num14;
			}
		}
		private static void q_p(ref short short_0, int int_0)
		{
			short num = short_0;
			if (int_0 < 5)
			{
				short_0 = ((num & 8) | (short)DefineConstants.gray[(int)(num & 7)]);
				return;
			}
			short_0 = (short)DefineConstants.gray[(int)(num & 7)];
		}
		private static void code_10i40_35bits(float[] float_0, int xOffset, float[] float_1, int cnOffset, float[] float_2, int hOffset, int T0, float gain_pit, float[] code, int codeOffset, float[] float_3, int yOffset, short[] anap, int anapOffset)
		{
			float[,] float_4 = new float[40, 40];
			float[] array = new float[40];
			float[] array2 = new float[40];
			int[] ipos = new int[10];
			int[] pos_max = new int[5];
			int[] codvec = new int[10];
			if (gain_pit > 1f)
			{
				gain_pit = 1f;
			}
			if (gain_pit != 0f)
			{
				for (int i = T0; i < 40; i++)
				{
					float_2[hOffset + i] += float_2[hOffset + i - T0] * gain_pit;
				}
			}
			GloabFunc.cor_h_x(float_2, hOffset, float_0, xOffset, array, 0);
			GloabFunc.set_sign12k2(array, 0, float_1, cnOffset, array2, 0, pos_max, 0, 5, ipos, 0, 5);
			GloabFunc.cor_h(float_2, hOffset, array2, 0, float_4);
			GloabFunc.search_10i40(array, 0, float_4, ipos, 0, pos_max, 0, codvec, 0);
			GloabFunc.build_code_10i40_35bits(codvec, 0, array2, 0, code, codeOffset, float_2, hOffset, float_3, yOffset, anap, anapOffset);
			for (int i = 0; i < 10; i++)
			{
				GloabFunc.q_p(ref anap[anapOffset + i], i);
			}
			if (gain_pit != 0f)
			{
				for (int i = T0; i < 40; i++)
				{
					code[codeOffset + i] += code[codeOffset + i - T0] * gain_pit;
				}
			}
		}
		private static void cbsearch(Mode mode, short subnr, float[] float_0, int xOffset, float[] float_1, int hOffset, int T0, float pitch_sharp, float gain_pit, float[] code, int codeOffset, float[] float_2, int yOffset, float[] res2, int res2Offset, ref short[] anap, ref int anapOffset)
		{
			switch (mode)
			{
			case Mode.MR475:
			case Mode.MR515:
				GloabFunc.code_2i40_9bits(subnr, float_0, xOffset, float_1, hOffset, T0, pitch_sharp, code, codeOffset, float_2, yOffset, anap, anapOffset);
				anapOffset += 2;
				return;
			case Mode.MR59:
				GloabFunc.code_2i40_11bits(float_0, xOffset, float_1, hOffset, T0, pitch_sharp, code, codeOffset, float_2, yOffset, anap, anapOffset);
				anapOffset += 2;
				return;
			case Mode.MR67:
				GloabFunc.code_3i40_14bits(float_0, xOffset, float_1, hOffset, T0, pitch_sharp, code, codeOffset, float_2, yOffset, anap, anapOffset);
				anapOffset += 2;
				return;
			case Mode.MR74:
			case Mode.MR795:
				GloabFunc.code_4i40_17bits(float_0, xOffset, float_1, hOffset, T0, pitch_sharp, code, codeOffset, float_2, yOffset, anap, anapOffset);
				anapOffset += 2;
				return;
			case Mode.MR102:
				GloabFunc.code_8i40_31bits(float_0, xOffset, res2, res2Offset, float_1, hOffset, T0, pitch_sharp, code, codeOffset, float_2, yOffset, anap, anapOffset);
				anapOffset += 7;
				return;
			default:
				GloabFunc.code_10i40_35bits(float_0, xOffset, res2, res2Offset, float_1, hOffset, T0, gain_pit, code, codeOffset, float_2, yOffset, anap, anapOffset);
				anapOffset += 10;
				return;
			}
		}
		private static void Log2_norm(int int_0, int int_1, ref int exponent, ref int fraction)
		{
			if (int_0 <= 0)
			{
				exponent = 0;
				fraction = 0;
				return;
			}
			int num = int_0 >> 25;
			num -= 32;
			int num2 = int_0 >> 9;
			num2 &= 65534;
			int num3 = (DefineConstants.log2_table[num] << 16) - num2 * (DefineConstants.log2_table[num] - DefineConstants.log2_table[num + 1]);
			fraction = num3 >> 16;
			exponent = 30 - int_1;
		}
		private static void Log2(int int_0, ref int exponent, ref int fraction)
		{
			int num = 0;
			GloabFunc.frexp((double)int_0, ref num);
			num = 31 - num;
			GloabFunc.Log2_norm(int_0 << num, num, ref exponent, ref fraction);
		}
		private static int Pow2(int exponent, int fraction)
		{
			int num = fraction >> 10;
			int num2 = fraction << 5 & 32767;
			int num3 = DefineConstants.pow2_table[num] << 16;
			int num4 = DefineConstants.pow2_table[num] - DefineConstants.pow2_table[num + 1];
			num3 -= num4 * num2 << 1;
			if (exponent >= -1)
			{
				int num5 = 30 - exponent;
				if ((num3 & 1 << num5 - 1) != 0)
				{
					num3 = (num3 >> num5) + 1;
				}
				else
				{
					num3 >>= num5;
				}
			}
			else
			{
				num3 = 0;
			}
			return num3;
		}
		private static void gc_pred(int[] past_qua_en, int past_qua_enOffset, Mode mode, float[] code, int codeOffset, ref int gcode0_exp, ref int gcode0_fra, ref float float_0)
		{
			int num = 0;
			int num2 = 0;
			int num3 = 0;
			double num4 = (double)GloabFunc.Dotproduct40(code, codeOffset, code, codeOffset);
			int num5;
			if (mode == Mode.MR122)
			{
				num5 = (int)(num4 * 33554432.0);
				num5 = (int)((long)num5 + 32768L >> 16) * 52428;
				GloabFunc.Log2(num5, ref num, ref num2);
				num5 = (num - 30 << 16) + (num2 << 1);
				int num6 = 44 * DefineConstants.qua_gain_code_MR122[past_qua_en[past_qua_enOffset]];
				num6 += 37 * DefineConstants.qua_gain_code_MR122[past_qua_en[past_qua_enOffset + 1]];
				num6 += 22 * DefineConstants.qua_gain_code_MR122[past_qua_en[past_qua_enOffset + 2]];
				num6 += 12 * DefineConstants.qua_gain_code_MR122[past_qua_en[past_qua_enOffset + 3]];
				num6 <<= 1;
				num6 += 783741;
				num5 = num6 - num5 >> 1;
				gcode0_exp = num5 >> 16;
				gcode0_fra = (num5 >> 1) - (gcode0_exp << 15);
				return;
			}
			num5 = (int)(num4 * 134217728.0);
			if (num5 < 0)
			{
				num5 = 2147483647;
			}
			GloabFunc.frexp((double)num5, ref num3);
			num3 = 31 - num3;
			num5 <<= num3;
			GloabFunc.Log2_norm(num5, num3, ref num, ref num2);
			int num7 = num * -49320 + (num2 * -24660 >> 15 << 1);
			if (mode == Mode.MR102)
			{
				num7 += 2134784;
			}
			else
			{
				if (mode == Mode.MR795)
				{
					num7 += 2183936;
					float_0 = (float)num4;
				}
				else
				{
					if (mode == Mode.MR74)
					{
						num7 += 2085632;
					}
					else
					{
						if (mode == Mode.MR67)
						{
							num7 += 2065152;
						}
						else
						{
							num7 += 2134784;
						}
					}
				}
			}
			num7 <<= 9;
			num7 += 5571 * DefineConstants.qua_gain_code[past_qua_en[past_qua_enOffset]];
			num7 += 4751 * DefineConstants.qua_gain_code[past_qua_en[past_qua_enOffset + 1]];
			num7 += 2785 * DefineConstants.qua_gain_code[past_qua_en[past_qua_enOffset + 2]];
			num7 += 1556 * DefineConstants.qua_gain_code[past_qua_en[past_qua_enOffset + 3]];
			num7 >>= 15;
			if (mode == Mode.MR74)
			{
				num7 *= 10878;
			}
			else
			{
				num7 *= 10886;
			}
			num7 >>= 9;
			gcode0_exp = num7 >> 15;
			gcode0_fra = num7 - gcode0_exp * 32768;
		}
		private static void calc_filt_energies(Mode mode, float[] float_0, int xnOffset, float[] float_1, int xn2Offset, float[] float_2, int y1Offset, float[] float_3, int y2Offset, float[] gCoeff, int gCoeffOffset, float[] coeff, int coeffOffset, ref float cod_gain)
		{
			float num = 0.01f;
			if (mode == Mode.MR795 || mode == Mode.MR475)
			{
				num = 0f;
			}
			coeff[coeffOffset] = gCoeff[gCoeffOffset];
			coeff[coeffOffset + 1] = -2f * gCoeff[gCoeffOffset + 1];
			float num2 = GloabFunc.Dotproduct40(float_3, y2Offset, float_3, y2Offset);
			num2 += num;
			coeff[coeffOffset + 2] = num2;
			num2 = GloabFunc.Dotproduct40(float_0, xnOffset, float_3, y2Offset);
			num2 += num;
			coeff[coeffOffset + 3] = -2f * num2;
			num2 = GloabFunc.Dotproduct40(float_2, y1Offset, float_3, y2Offset);
			num2 += num;
			coeff[coeffOffset + 4] = 2f * num2;
			if (mode == Mode.MR475 || mode == Mode.MR795)
			{
				num2 = GloabFunc.Dotproduct40(float_1, xn2Offset, float_3, y2Offset);
				if (num2 <= 0f)
				{
					cod_gain = 0f;
					return;
				}
				cod_gain = num2 / coeff[coeffOffset + 2];
			}
		}
		private static void MR475_update_unq_pred(int[] past_qua_en, int past_qua_enOffset, float gcode0, float cod_gain)
		{
			float num;
			if (cod_gain <= 0f)
			{
				num = -32f;
			}
			else
			{
				float num2;
				if (gcode0 != 0f)
				{
					num2 = cod_gain / gcode0;
				}
				else
				{
					num2 = 10f;
				}
				if (num2 < 0.0251189f)
				{
					num = -32f;
				}
				else
				{
					if (num2 > 7.8125f)
					{
						num = 17.8558f;
					}
					else
					{
						num = (float)(20.0 * Math.Log10((double)num2));
					}
				}
			}
			int num3 = (int)(num * 1024f + 0.5f);
			int num4 = Math.Abs(num3 - DefineConstants.qua_gain_code[0]);
			int num5 = 0;
			for (int i = 1; i < 739; i++)
			{
				int num6 = Math.Abs(num3 - DefineConstants.qua_gain_code[i]);
				if (num6 < num4)
				{
					num4 = num6;
					num5 = i;
					if (num6 == 0)
					{
						break;
					}
				}
			}
			for (int i = 3; i > 0; i--)
			{
				past_qua_en[past_qua_enOffset + i] = past_qua_en[past_qua_enOffset + i - 1];
			}
			past_qua_en[past_qua_enOffset] = num5;
		}
		private static short MR475_gain_quant(int[] past_qua_en, int past_qua_enOffset, int sf0_gcode0_exp, int sf0_gcode0_fra, float[] sf0_coeff, int sf0_coeffOffset, float sf0_target_en, float[] sf1_code_nosharp, int sf1_code_nosharpOffset, int sf1_gcode0_exp, int sf1_gcode0_fra, float[] sf1_coeff, int sf1_coeffOffset, float sf1_target_en, float gp_limit, ref float sf0_gain_pit, ref float sf0_gain_cod, ref float sf1_gain_pit, ref float sf1_gain_cod)
		{
			int num = 0;
			float num2 = (float)GloabFunc.Pow2(sf0_gcode0_exp, sf0_gcode0_fra);
			float num3 = (float)GloabFunc.Pow2(sf1_gcode0_exp, sf1_gcode0_fra);
			if (sf0_target_en * 2f < sf1_target_en)
			{
				sf0_coeff[sf0_coeffOffset] *= 2f;
				sf0_coeff[sf0_coeffOffset + 1] *= 2f;
				sf0_coeff[sf0_coeffOffset + 2] *= 2f;
				sf0_coeff[sf0_coeffOffset + 3] *= 2f;
				sf0_coeff[sf0_coeffOffset + 4] *= 2f;
			}
			else
			{
				if (sf0_target_en > sf1_target_en * 4f)
				{
					sf1_coeff[sf1_coeffOffset] *= 2f;
					sf1_coeff[sf1_coeffOffset + 1] *= 2f;
					sf1_coeff[sf1_coeffOffset + 2] *= 2f;
					sf1_coeff[sf1_coeffOffset + 3] *= 2f;
					sf1_coeff[sf1_coeffOffset + 4] *= 2f;
				}
			}
			float num4 = 3.40282347E+38f;
			float[] table_gain_MR = DefineConstants.table_gain_MR475;
			int num5 = 0;
			for (int i = 0; i < 256; i++)
			{
				float num6 = table_gain_MR[num5++];
				float num7 = table_gain_MR[num5++];
				num7 *= num2;
				float num8 = num6 * num6;
				float num9 = num7 * num7;
				float num10 = num7 * num6;
				float num11 = sf0_coeff[sf0_coeffOffset] * num8;
				num11 += sf0_coeff[sf0_coeffOffset + 1] * num6;
				num11 += sf0_coeff[sf0_coeffOffset + 2] * num9;
				num11 += sf0_coeff[sf0_coeffOffset + 3] * num7;
				num11 += sf0_coeff[sf0_coeffOffset + 4] * num10;
				float num12 = num6 - gp_limit;
				num6 = table_gain_MR[num5++];
				num7 = table_gain_MR[num5++];
				if (num12 <= 0f && num6 <= gp_limit)
				{
					num7 *= num3;
					num8 = num6 * num6;
					num9 = num7 * num7;
					num10 = num7 * num6;
					num11 += sf1_coeff[sf1_coeffOffset] * num8;
					num11 += sf1_coeff[sf1_coeffOffset + 1] * num6;
					num11 += sf1_coeff[sf1_coeffOffset + 2] * num9;
					num11 += sf1_coeff[sf1_coeffOffset + 3] * num7;
					num11 += sf1_coeff[sf1_coeffOffset + 4] * num10;
					if (num11 < num4)
					{
						num4 = num11;
						num = i;
					}
				}
			}
			int num13 = num << 2;
			table_gain_MR = DefineConstants.table_gain_MR475;
			num5 = num13;
			sf0_gain_pit = table_gain_MR[num5++];
			int num14 = (int)(table_gain_MR[num5++] * 4096f + 0.5f);
			int num15 = GloabFunc.Pow2(14, sf0_gcode0_fra);
			if (sf0_gcode0_exp < 11)
			{
				sf0_gain_cod = (float)(num14 * num15 >> 25 - sf0_gcode0_exp);
			}
			else
			{
				int i = num14 * num15 << sf0_gcode0_exp - 9;
				if (i >> sf0_gcode0_exp - 9 != num14 * num15)
				{
					sf0_gain_cod = 32767f;
				}
				else
				{
					sf0_gain_cod = (float)(i >> 16);
				}
			}
			sf0_gain_cod *= 0.5f;
			for (int i = 3; i > 0; i--)
			{
				past_qua_en[past_qua_enOffset + i] = past_qua_en[past_qua_enOffset + i - 1];
			}
			past_qua_en[past_qua_enOffset] = 224 + (num << 1);
			GloabFunc.gc_pred(past_qua_en, past_qua_enOffset, Mode.MR475, sf1_code_nosharp, sf1_code_nosharpOffset, ref sf1_gcode0_exp, ref sf1_gcode0_fra, ref num2);
			num13 += 2;
			table_gain_MR = DefineConstants.table_gain_MR475;
			num5 = num13;
			sf1_gain_pit = table_gain_MR[num5++];
			num14 = (int)(table_gain_MR[num5++] * 4096f + 0.5f);
			num15 = GloabFunc.Pow2(14, sf1_gcode0_fra);
			if (sf1_gcode0_exp < 11)
			{
				sf1_gain_cod = (float)(num14 * num15 >> 25 - sf1_gcode0_exp);
			}
			else
			{
				int i = num14 * num15 << sf1_gcode0_exp - 9;
				if (i >> sf1_gcode0_exp - 9 != num14 * num15)
				{
					sf1_gain_cod = 32767f;
				}
				else
				{
					sf1_gain_cod = (float)(i >> 16);
				}
			}
			sf1_gain_cod *= 0.5f;
			for (int i = 3; i > 0; i--)
			{
				past_qua_en[past_qua_enOffset + i] = past_qua_en[past_qua_enOffset + i - 1];
			}
			past_qua_en[past_qua_enOffset] = 224 + (num << 1) + 1;
			return (short)num;
		}
		private static short q_gain_code(float gcode0, ref float gain, ref int qua_ener_index)
		{
			float[] gain_factor = DefineConstants.gain_factor;
			float arg_15_0 = gain;
			float[] arg_13_0 = gain_factor;
			int expr_0F = 0;
			int num = expr_0F + 1;
			double num2 = (double)Math.Abs(arg_15_0 - gcode0 * arg_13_0[expr_0F]);
			int num3 = 0;
			for (int i = 1; i < 32; i++)
			{
				double num4 = (double)Math.Abs(gain - gcode0 * gain_factor[num++]);
				if (num4 < num2)
				{
					num2 = num4;
					num3 = i;
				}
			}
			gain_factor = DefineConstants.gain_factor;
			num = num3;
			gain = (float)Math.Floor((double)(gcode0 * gain_factor[num]));
			qua_ener_index = num3;
			return (short)num3;
		}
		private static void MR795_gain_code_quant3(int gcode0_exp, int gcode0_fra, float[] g_pitch_cand, int g_pitch_candOffset, int[] g_pitch_cind, int g_pitch_cindOffset, float[] coeff, int coeffOffset, ref float gain_pit, ref int gain_pit_ind, ref float gain_cod, ref int gain_cod_ind, ref int qua_ener_index)
		{
			float num = (float)GloabFunc.Pow2(gcode0_exp, gcode0_fra);
			float num2 = 3.40282347E+38f;
			int num3 = 0;
			int num4 = 0;
			float[] gain_factor;
			int num8;
			int j;
			for (int i = 0; i < 3; i++)
			{
				float num5 = g_pitch_cand[g_pitch_candOffset + i];
				float num6 = num5 * num5;
				float num7 = coeff[coeffOffset] * num6;
				num7 += coeff[coeffOffset + 1] * num5;
				gain_factor = DefineConstants.gain_factor;
				num8 = 0;
				for (j = 0; j < 32; j++)
				{
					float num9 = gain_factor[num8++];
					num9 *= num;
					float num10 = num9 * num9;
					float num11 = num9 * num5;
					float num12 = num7 + coeff[coeffOffset + 2] * num10;
					num12 += coeff[coeffOffset + 3] * num9;
					num12 += coeff[coeffOffset + 4] * num11;
					if (num12 < num2)
					{
						num2 = num12;
						num3 = j;
						num4 = i;
					}
				}
			}
			gain_factor = DefineConstants.gain_factor;
			num8 = num3;
			int num13 = (int)(2048f * gain_factor[num8]);
			qua_ener_index = num3;
			int num14 = GloabFunc.Pow2(14, gcode0_fra);
			j = num13 * num14 << 1;
			gcode0_exp = 9 - gcode0_exp;
			if (gcode0_exp > 0)
			{
				j >>= gcode0_exp;
			}
			else
			{
				j <<= -gcode0_exp;
			}
			gain_cod = (float)(j >> 16);
			if (gain_cod > 32767f)
			{
				gain_cod = 32767f;
			}
			gain_cod *= 0.5f;
			gain_cod_ind = (int)((short)num3);
			gain_pit = g_pitch_cand[g_pitch_candOffset + num4];
			gain_pit_ind = g_pitch_cind[g_pitch_cindOffset + num4];
		}
		private static void calc_unfilt_energies(float[] float_0, int resOffset, float[] float_1, int excOffset, float[] code, int codeOffset, float gain_pit, float[] float_2, int enOffset, ref float ltpg)
		{
			float_2[enOffset] = GloabFunc.Dotproduct40(float_0, resOffset, float_0, resOffset);
			if (float_2[enOffset] < 200f)
			{
				float_2[enOffset] = 0f;
			}
			float_2[enOffset + 1] = GloabFunc.Dotproduct40(float_1, excOffset, float_1, excOffset);
			float_2[enOffset + 2] = GloabFunc.Dotproduct40(float_1, excOffset, code, codeOffset);
			float_2[enOffset + 3] = 0f;
			for (int i = 0; i < 40; i++)
			{
				float num = float_0[resOffset + i] - float_1[excOffset + i] * gain_pit;
				float_2[enOffset + 3] += num * num;
			}
			if (float_2[enOffset + 3] > 0f && float_2[enOffset] != 0f)
			{
				float num2 = float_2[enOffset] / float_2[enOffset + 3];
				ltpg = (float)(Math.Log10((double)num2) / Math.Log10(2.0));
				return;
			}
			ltpg = 0f;
		}
		private static float gmed_n_f(float[] float_0, int indOffset, short short_0)
		{
			int num = 0;
			int[] array = new int[9];
			float[] array2 = new float[9];
			for (int i = 0; i < (int)short_0; i++)
			{
				array2[i] = float_0[indOffset + i];
			}
			for (int i = 0; i < (int)short_0; i++)
			{
				float num2 = -3.40282347E+38f;
				for (int j = 0; j < (int)short_0; j++)
				{
					if (array2[j] >= num2)
					{
						num2 = array2[j];
						num = j;
					}
				}
				array2[num] = -3.40282347E+38f;
				array[i] = num;
			}
			int num3 = array[short_0 >> 1];
			return float_0[indOffset + num3];
		}
		private static void gain_adapt(ref float prev_gc, ref short onset, float[] ltpg_mem, int ltpg_memOffset, ref float prev_alpha, float ltpg, float gain_cod, ref float alpha)
		{
			short num;
			if (ltpg <= 0.3321928f)
			{
				num = 0;
			}
			else
			{
				if ((double)ltpg <= 0.6643856)
				{
					num = 1;
				}
				else
				{
					num = 2;
				}
			}
			if (gain_cod > 2f * prev_gc && gain_cod > 100f)
			{
				onset = 8;
			}
			else
			{
				if (onset != 0)
				{
					onset -= 1;
				}
			}
			if (onset != 0 && num < 2)
			{
				num += 1;
			}
			ltpg_mem[ltpg_memOffset] = ltpg;
			float num2 = GloabFunc.gmed_n_f(ltpg_mem, ltpg_memOffset, 5);
			float num3;
			if (num == 0)
			{
				if ((double)num2 > 0.66443)
				{
					num3 = 0f;
				}
				else
				{
					if (num2 < 0f)
					{
						num3 = 0.5f;
					}
					else
					{
						num3 = (float)(0.5 - 0.75257499 * (double)num2);
					}
				}
			}
			else
			{
				num3 = 0f;
			}
			if (prev_alpha == 0f)
			{
				num3 = 0.5f * num3;
			}
			alpha = num3;
			prev_alpha = num3;
			prev_gc = gain_cod;
			for (int i = 4; i > 0; i--)
			{
				ltpg_mem[ltpg_memOffset + i] = ltpg_mem[ltpg_memOffset + i - 1];
			}
		}
		private static short MR795_gain_code_quant_mod(float gain_pit, int gcode0_exp, int gcode0_fra, float[] float_0, int enOffset, float alpha, float gain_cod_unq, ref float gain_cod, ref int qua_ener_index)
		{
			float[] array = new float[5];
			float num = (float)GloabFunc.Pow2(gcode0_exp, gcode0_fra);
			float num2 = gain_cod;
			float num3 = gain_pit * gain_pit;
			array[0] = (float)Math.Sqrt((double)(alpha * float_0[enOffset]));
			array[1] = alpha * float_0[enOffset + 1] * num3;
			array[2] = 2f * alpha * float_0[enOffset + 2] * gain_pit;
			array[3] = alpha * float_0[enOffset + 3];
			array[4] = (1f - alpha) * float_0[enOffset + 3];
			float num4 = 3.40282347E+38f;
			int num5 = 0;
			float[] gain_factor = DefineConstants.gain_factor;
			int num6 = 0;
			int i;
			for (i = 0; i < 32; i++)
			{
				float num7 = gain_factor[num6++];
				num7 *= num;
				if (num7 >= 2f * num2)
				{
					break;
				}
				float num8 = num7 * num7;
				float num9 = num7 - gain_cod_unq;
				num9 *= num9;
				float num10 = array[1] + array[2] * num7;
				num10 += array[3] * num8;
				num10 = (float)Math.Sqrt((double)num10);
				num10 -= array[0];
				num10 *= num10;
				num10 += array[4] * num9;
				if (num10 < num4)
				{
					num4 = num10;
					num5 = i;
				}
			}
			gain_factor = DefineConstants.gain_factor;
			num6 = num5;
			int num11 = (int)(2048f * gain_factor[num6]);
			qua_ener_index = num5;
			int num12 = GloabFunc.Pow2(14, gcode0_fra);
			i = num11 * num12 << 1;
			gcode0_exp = 9 - gcode0_exp;
			if (gcode0_exp > 0)
			{
				i >>= gcode0_exp;
			}
			else
			{
				i <<= -gcode0_exp;
			}
			gain_cod = (float)(i >> 16);
			if (gain_cod > 32767f)
			{
				gain_cod = 32767f;
			}
			gain_cod *= 0.5f;
			return (short)num5;
		}
		private static void MR795_gain_quant(ref float prev_gc, ref short onset, float[] ltpg_mem, int ltpg_memOffset, ref float prev_alpha, float[] float_0, int resOffset, float[] float_1, int excOffset, float[] code, int codeOffset, float[] coeff, int coeffOffset, float code_en, int gcode0_exp, int gcode0_fra, float cod_gain, float gp_limit, ref float gain_pit, ref float gain_cod, ref int qua_ener_index, ref short[] anap, ref int anapOffset)
		{
			float[] array = new float[4];
			float[] array2 = new float[3];
			float ltpg = 0f;
			float num = 0f;
			int[] array3 = new int[3];
			int num2 = 0;
			int num3 = 0;
			num2 = (int)GloabFunc.q_gain_pitch(Mode.MR795, gp_limit, ref gain_pit, array2, 0, array3, 0);
			GloabFunc.MR795_gain_code_quant3(gcode0_exp, gcode0_fra, array2, 0, array3, 0, coeff, coeffOffset, ref gain_pit, ref num2, ref gain_cod, ref num3, ref qua_ener_index);
			GloabFunc.calc_unfilt_energies(float_0, resOffset, float_1, excOffset, code, codeOffset, gain_pit, array, 0, ref ltpg);
			GloabFunc.gain_adapt(ref prev_gc, ref onset, ltpg_mem, ltpg_memOffset, ref prev_alpha, ltpg, gain_cod, ref num);
			if (array[0] != 0f && num > 0f)
			{
				array[3] = code_en;
				num3 = (int)GloabFunc.MR795_gain_code_quant_mod(gain_pit, gcode0_exp, gcode0_fra, array, 0, num, cod_gain, ref gain_cod, ref qua_ener_index);
			}
			anap[anapOffset++] = (short)num2;
			anap[anapOffset++] = (short)num3;
		}
		private static short Qua_gain(Mode mode, int gcode0_exp, int gcode0_fra, float[] coeff, int coeffOffset, float gp_limit, ref float gain_pit, ref float gain_cod, ref int qua_ener_index)
		{
			int num = 0;
			float num2 = (float)GloabFunc.Pow2(gcode0_exp, gcode0_fra);
			short num3;
			float[] array;
			if (mode != Mode.MR102 && mode != Mode.MR74)
			{
				if (mode != Mode.MR67)
				{
					num3 = 64;
					array = DefineConstants.table_lowrates;
					qua_ener_index = 160;
					goto IL_41;
				}
			}
			num3 = 128;
			array = DefineConstants.table_highrates;
			qua_ener_index = 32;
			IL_41:
			float num4 = 3.40282347E+38f;
			float[] array2 = array;
			int num5 = 0;
			for (int i = 0; i < (int)num3; i++)
			{
				float num6 = array2[num5++];
				float num7 = array2[num5++];
				if (num6 <= gp_limit)
				{
					num7 *= num2;
					float num8 = num6 * num6;
					float num9 = num7 * num7;
					float num10 = num7 * num6;
					float num11 = coeff[coeffOffset] * num8;
					num11 += coeff[coeffOffset + 1] * num6;
					num11 += coeff[coeffOffset + 2] * num9;
					num11 += coeff[coeffOffset + 3] * num7;
					num11 += coeff[coeffOffset + 4] * num10;
					if (num11 < num4)
					{
						num4 = num11;
						num = i;
					}
				}
			}
			array2 = array;
			num5 = num << 1;
			gain_pit = array2[num5++];
			int num12 = (int)(4096f * array2[num5]);
			int num13 = GloabFunc.Pow2(14, gcode0_fra);
			if (gcode0_exp < 11)
			{
				gain_cod = (float)(num12 * num13 >> 25 - gcode0_exp);
			}
			else
			{
				int i = num12 * num13 << gcode0_exp - 9;
				if (i >> gcode0_exp - 9 != num12 * num13)
				{
					gain_cod = 32767f;
				}
				else
				{
					gain_cod = (float)(i >> 16);
				}
			}
			gain_cod *= 0.5f;
			qua_ener_index += num;
			return (short)num;
		}
		private static void gainQuant(Mode mode, int even_subframe, int[] past_qua_en, int past_qua_enOffset, int[] past_qua_en_unq, int past_qua_en_unqOffset, float[] sf0_coeff, int sf0_coeffOffset, ref float sf0_target_en, ref int sf0_gcode0_exp, ref int sf0_gcode0_fra, ref short[] gain_idx_ptr, ref int gain_idx_ptrOffset, ref float sf0_gain_pit, ref float sf0_gain_cod, float[] float_0, int resOffset, float[] float_1, int excOffset, float[] code, int codeOffset, float[] float_2, int xnOffset, float[] float_3, int xn2Offset, float[] float_4, int y1Offset, float[] float_5, int y2Offset, float[] gCoeff, int gCoeffOffset, float gp_limit, ref float gain_pit, ref float gain_cod, ref float prev_gc, ref short onset, float[] ltpg_mem, int ltpg_memOffset, ref float prev_alpha, ref short[] anap, ref int anapOffset)
		{
			float[] array = new float[5];
			float num = 0f;
			float num2 = 0f;
			int num3 = 0;
			int num4 = 0;
			int num5 = 0;
			if (mode != Mode.MR475)
			{
				GloabFunc.gc_pred(past_qua_en, past_qua_enOffset, mode, code, codeOffset, ref num3, ref num4, ref num2);
				if (mode == Mode.MR122)
				{
					float num6 = (float)GloabFunc.Pow2(num3, num4);
					if (num6 > 2047.9375f)
					{
						num6 = 2047.9375f;
					}
					gain_cod = GloabFunc.Dotproduct40(float_3, xn2Offset, float_5, y2Offset) / (GloabFunc.Dotproduct40(float_5, y2Offset, float_5, y2Offset) + 0.01f);
					if (gain_cod < 0f)
					{
						gain_cod = 0f;
					}
					anap[anapOffset] = GloabFunc.q_gain_code(num6, ref gain_cod, ref num5);
					anapOffset++;
				}
				else
				{
					GloabFunc.calc_filt_energies(mode, float_2, xnOffset, float_3, xn2Offset, float_4, y1Offset, float_5, y2Offset, gCoeff, gCoeffOffset, array, 0, ref num);
					if (mode == Mode.MR795)
					{
						GloabFunc.MR795_gain_quant(ref prev_gc, ref onset, ltpg_mem, ltpg_memOffset, ref prev_alpha, float_0, resOffset, float_1, excOffset, code, codeOffset, array, 0, num2, num3, num4, num, gp_limit, ref gain_pit, ref gain_cod, ref num5, ref anap, ref anapOffset);
					}
					else
					{
						anap[anapOffset] = GloabFunc.Qua_gain(mode, num3, num4, array, 0, gp_limit, ref gain_pit, ref gain_cod, ref num5);
						anapOffset++;
					}
				}
				for (int i = 3; i > 0; i--)
				{
					past_qua_en[past_qua_enOffset + i] = past_qua_en[past_qua_enOffset + i - 1];
				}
				past_qua_en[past_qua_enOffset] = num5;
				return;
			}
			if (even_subframe != 0)
			{
				gain_idx_ptr = anap;
				gain_idx_ptrOffset = anapOffset;
				anapOffset++;
				past_qua_en_unq[past_qua_en_unqOffset] = past_qua_en[past_qua_enOffset];
				past_qua_en_unq[past_qua_en_unqOffset + 1] = past_qua_en[past_qua_enOffset + 1];
				past_qua_en_unq[past_qua_en_unqOffset + 2] = past_qua_en[past_qua_enOffset + 2];
				past_qua_en_unq[past_qua_en_unqOffset + 3] = past_qua_en[past_qua_enOffset + 3];
				GloabFunc.gc_pred(past_qua_en, past_qua_enOffset, mode, code, codeOffset, ref sf0_gcode0_exp, ref sf0_gcode0_fra, ref num2);
				float num6 = (float)GloabFunc.Pow2(sf0_gcode0_exp, sf0_gcode0_fra);
				GloabFunc.calc_filt_energies(mode, float_2, xnOffset, float_3, xn2Offset, float_4, y1Offset, float_5, y2Offset, gCoeff, gCoeffOffset, sf0_coeff, sf0_coeffOffset, ref num);
				gain_cod = num;
				sf0_target_en = GloabFunc.Dotproduct40(float_2, xnOffset, float_2, xnOffset);
				GloabFunc.MR475_update_unq_pred(past_qua_en_unq, past_qua_en_unqOffset, num6, num);
				return;
			}
			GloabFunc.gc_pred(past_qua_en_unq, past_qua_en_unqOffset, mode, code, codeOffset, ref num3, ref num4, ref num2);
			GloabFunc.calc_filt_energies(mode, float_2, xnOffset, float_3, xn2Offset, float_4, y1Offset, float_5, y2Offset, gCoeff, gCoeffOffset, array, 0, ref num);
			num2 = GloabFunc.Dotproduct40(float_2, xnOffset, float_2, xnOffset);
			gain_idx_ptr[gain_idx_ptrOffset] = GloabFunc.MR475_gain_quant(past_qua_en, past_qua_enOffset, sf0_gcode0_exp, sf0_gcode0_fra, sf0_coeff, sf0_coeffOffset, sf0_target_en, code, codeOffset, num3, num4, array, 0, num2, gp_limit, ref sf0_gain_pit, ref sf0_gain_cod, ref gain_pit, ref gain_cod);
		}
		private static void subframePostProc(float[] speech, int speechOffset, short i_subfr, float gain_pit, float gain_code, float[] a_q, int a_qOffset, float[] synth, int synthOffset, float[] float_0, int xnOffset, float[] code, int codeOffset, float[] float_1, int y1Offset, float[] float_2, int y2Offset, float[] mem_syn, int mem_synOffset, float[] mem_err, int mem_errOffset, float[] mem_w0, int mem_w0Offset, float[] float_3, int excOffset, ref float sharp)
		{
			sharp = gain_pit;
			if (sharp > 0.794556f)
			{
				sharp = 0.794556f;
			}
			int i;
			for (i = 0; i < 40; i += 4)
			{
				float_3[excOffset + i + (int)i_subfr] = (float)Math.Floor((double)(gain_pit * float_3[excOffset + i + (int)i_subfr] + gain_code * code[codeOffset + i] + 0.5f));
				float_3[excOffset + i + (int)i_subfr + 1] = (float)Math.Floor((double)(gain_pit * float_3[excOffset + i + (int)i_subfr + 1] + gain_code * code[codeOffset + i + 1] + 0.5f));
				float_3[excOffset + i + (int)i_subfr + 2] = (float)Math.Floor((double)(gain_pit * float_3[excOffset + i + (int)i_subfr + 2] + gain_code * code[codeOffset + i + 2] + 0.5f));
				float_3[excOffset + i + (int)i_subfr + 3] = (float)Math.Floor((double)(gain_pit * float_3[excOffset + i + (int)i_subfr + 3] + gain_code * code[codeOffset + i + 3] + 0.5f));
			}
			GloabFunc.Syn_filt(a_q, a_qOffset, float_3, excOffset + (int)i_subfr, synth, synthOffset + (int)i_subfr, mem_syn, mem_synOffset, 1);
			i = 30;
			int num = 0;
			while (i < 40)
			{
				mem_err[mem_errOffset + num] = speech[speechOffset + (int)i_subfr + i] - synth[synthOffset + (int)i_subfr + i];
				mem_w0[mem_w0Offset + num] = float_0[xnOffset + i] - float_1[y1Offset + i] * gain_pit - float_2[y2Offset + i] * gain_code;
				i++;
				num++;
			}
		}
		private static void Convolve(float[] float_0, int xOffset, float[] float_1, int hOffset, float[] float_2, int yOffset)
		{
			for (int i = 0; i < 40; i++)
			{
				float num = 0f;
				for (int j = 0; j <= i; j++)
				{
					num += float_0[xOffset + j] * float_1[hOffset + i - j];
				}
				float_2[yOffset + i] = num;
			}
		}
		private static short tx_dtx_handler(short vad_flag, ref short decAnaElapsedCount, ref short dtxHangoverCount, ref Mode used_mode)
		{
			decAnaElapsedCount += 1;
			short result = 0;
			if (vad_flag != 0)
			{
				dtxHangoverCount = 7;
			}
			else
			{
				if (dtxHangoverCount == 0)
				{
					decAnaElapsedCount = 0;
					used_mode = Mode.MRDTX;
					result = 1;
				}
				else
				{
					dtxHangoverCount -= 1;
					if (decAnaElapsedCount + dtxHangoverCount < 30)
					{
						used_mode = Mode.MRDTX;
					}
				}
			}
			return result;
		}
		private static void dtx_buffer(ref short hist_ptr, float[] lsp_hist, int lsp_histOffset, float[] lsp_new, int lsp_newOffset, float[] speech, int speechOffset, float[] log_en_hist, int log_en_histOffset)
		{
			hist_ptr += 1;
			if (hist_ptr == 8)
			{
				hist_ptr = 0;
			}
			GloabFunc.memcpyFloat(lsp_hist, lsp_histOffset + (int)(hist_ptr * 10), lsp_new, lsp_newOffset, 10);
			double num = (double)GloabFunc.Dotproduct40(speech, speechOffset, speech, speechOffset);
			num += (double)GloabFunc.Dotproduct40(speech, speechOffset + 40, speech, speechOffset + 40);
			num += (double)GloabFunc.Dotproduct40(speech, speechOffset + 80, speech, speechOffset + 80);
			num += (double)GloabFunc.Dotproduct40(speech, speechOffset + 120, speech, speechOffset + 120);
			if (num > 1.0)
			{
				log_en_hist[log_en_histOffset + (int)hist_ptr] = (float)(Math.Log10(num * 0.0062500000931322575) * 1.6609640121459961);
				return;
			}
			log_en_hist[log_en_histOffset + (int)hist_ptr] = -3.660965f;
		}
		private static int dtx_enc(ref short log_en_index, float[] log_en_hist, int log_en_histOffset, float[] lsp_hist, int lsp_histOffset, short[] lsp_index, int lsp_indexOffset, ref int init_lsf_vq_index, short compute_sid_flag, float[] past_rq, int past_rqOffset, int[] past_qua_en, int past_qua_enOffset, ref short[] anap, ref int anapOffset)
		{
			float[] array = new float[10];
			float[] array2 = new float[10];
			float[] lsp1_q = new float[10];
			if (compute_sid_flag != 0)
			{
				float num = 0f;
				GloabFunc.memsetFloat(array2, 0, 0f, 40);
				for (int i = 0; i < 8; i++)
				{
					num += log_en_hist[log_en_histOffset + i];
					for (int j = 0; j < 10; j++)
					{
						array2[j] += lsp_hist[lsp_histOffset + i * 10 + j];
					}
				}
				num *= 0.125f;
				for (int j = 0; j < 10; j++)
				{
					array2[j] *= 0.125f;
				}
				num += 2.5f;
				log_en_index = (short)(num * 4f + 0.5f);
				if (log_en_index > 63)
				{
					log_en_index = 63;
				}
				if (log_en_index < 0)
				{
					log_en_index = 0;
				}
				if (log_en_index > 46)
				{
					past_qua_en[past_qua_enOffset] = 782;
					past_qua_en[past_qua_enOffset + 1] = 782;
					past_qua_en[past_qua_enOffset + 2] = 782;
					past_qua_en[past_qua_enOffset + 3] = 782;
				}
				else
				{
					past_qua_en[past_qua_enOffset] = (int)(736 + log_en_index);
					past_qua_en[past_qua_enOffset + 1] = (int)(736 + log_en_index);
					past_qua_en[past_qua_enOffset + 2] = (int)(736 + log_en_index);
					past_qua_en[past_qua_enOffset + 3] = (int)(736 + log_en_index);
				}
				GloabFunc.Lsp_lsf(array2, 0, array, 0);
				GloabFunc.Reorder_lsf(array, 0, 0.00625f);
				GloabFunc.Lsf_lsp(array, 0, array2, 0);
				GloabFunc.Q_plsf_3(Mode.MRDTX, past_rq, past_rqOffset, array2, 0, lsp1_q, 0, lsp_index, lsp_indexOffset, ref init_lsf_vq_index);
			}
			anap[anapOffset] = (short)init_lsf_vq_index;
			anapOffset++;
			anap[anapOffset] = lsp_index[lsp_indexOffset];
			anapOffset++;
			anap[anapOffset] = lsp_index[lsp_indexOffset + 1];
			anapOffset++;
			anap[anapOffset] = lsp_index[lsp_indexOffset + 2];
			anapOffset++;
			anap[anapOffset] = log_en_index;
			anapOffset++;
			return 0;
		}
		private static int vad2(GloabFunc.vadState vadState_0, float[] farray_ptr, int farray_ptrOffset)
		{
			float[] array = new float[128];
			int[] array2 = new int[16];
			float[] array3 = new float[16];
			vadState_0.Lframe_cnt++;
			int i;
			for (i = 0; i < 24; i++)
			{
				array[i] = 0f;
			}
			array[24] = farray_ptr[farray_ptrOffset] + -0.8f * vadState_0.pre_emp_mem;
			i = 25;
			int j = 1;
			while (i < 104)
			{
				array[i] = farray_ptr[farray_ptrOffset + j] + -0.8f * farray_ptr[farray_ptrOffset + j - 1];
				i++;
				j++;
			}
			vadState_0.pre_emp_mem = farray_ptr[farray_ptrOffset + 80 - 1];
			for (i = 104; i < 128; i++)
			{
				array[i] = 0f;
			}
			GloabFunc.real_fft(array, 0, 1);
			float num = (float)((vadState_0.Lframe_cnt == 1) ? 1.0 : 0.55);
			for (i = 0; i <= 15; i++)
			{
				float num2 = 0f;
				int num3 = GloabFunc.ch_tbl[i, 0];
				int num4 = GloabFunc.ch_tbl[i, 1];
				for (j = num3; j <= num4; j++)
				{
					num2 += (float)(Math.Sqrt((double)array[2 * j]) + Math.Sqrt((double)array[2 * j + 1]));
				}
				num2 /= (float)(num4 - num3 + 1);
				vadState_0.ch_enrg[i] = (1f - num) * vadState_0.ch_enrg[i] + num * num2;
				if ((double)vadState_0.ch_enrg[i] < 0.015625)
				{
					vadState_0.ch_enrg[i] = 0.015625f;
				}
			}
			float num5 = 0f;
			for (i = 0; i <= 15; i++)
			{
				num5 += vadState_0.ch_enrg[i];
			}
			float num7;
			float num6 = num7 = 0f;
			for (i = 0; i <= 15; i++)
			{
				if (i >= 2 && vadState_0.ch_enrg[i] > num7)
				{
					num7 = vadState_0.ch_enrg[i];
				}
				num6 += vadState_0.ch_enrg[i];
			}
			num6 /= 16f;
			float num8 = ((double)num6 < 0.25) ? 0f : (10f * (float)Math.Log10((double)(num7 / num6)));
			int num9;
			if (num8 > 10f)
			{
				num9 = 1;
			}
			else
			{
				num9 = 0;
			}
			if (vadState_0.Lframe_cnt <= 4)
			{
				if (num9 == 1)
				{
					for (i = 0; i <= 15; i++)
					{
						vadState_0.ch_noise[i] = 4f;
					}
				}
				else
				{
					for (i = 0; i <= 15; i++)
					{
						vadState_0.ch_noise[i] = Math.Max(vadState_0.ch_enrg[i], 4f);
					}
				}
			}
			for (i = 0; i <= 15; i++)
			{
				float num10 = 10f * (float)Math.Log10((double)vadState_0.ch_enrg[i] / (double)vadState_0.ch_noise[i]);
				if ((double)num10 < 0.0)
				{
					num10 = 0f;
				}
				array2[i] = (int)((num10 + 0.1875f) / 0.375f);
			}
			int num11 = 0;
			for (i = 0; i <= 15; i++)
			{
				j = GloabFunc.smethod_0(array2[i], 89);
				num11 += GloabFunc.vm_tbl[j];
			}
			float num12;
			if (vadState_0.Lframe_cnt > 4 && vadState_0.fupdate_flag == 0)
			{
				num12 = 0f;
				for (i = 0; i <= 15; i++)
				{
					num12 += vadState_0.ch_enrg[i] / vadState_0.ch_noise[i];
				}
				num12 = 10f * (float)Math.Log10((double)(num12 / 16f));
				if (num12 > vadState_0.tsnr)
				{
					vadState_0.tsnr = 0.9f * vadState_0.tsnr + 0.1f * num12;
				}
				else
				{
					if (num12 > 0.625f * vadState_0.tsnr)
					{
						vadState_0.tsnr = 0.998f * vadState_0.tsnr + 0.002f * num12;
					}
				}
			}
			else
			{
				float num13 = 74f - 10f * (float)Math.Log10(64.0) - 10f * (float)Math.Log10(4.0);
				vadState_0.negSNRvar = 0f;
				vadState_0.negSNRbias = 0f;
				float num14 = 0f;
				for (i = 0; i <= 15; i++)
				{
					num14 += vadState_0.ch_noise[i];
				}
				float num15 = 10f * (float)Math.Log10((double)num14);
				num12 = num13 - num15;
				vadState_0.tsnr = num12;
			}
			int num16 = (int)(vadState_0.tsnr / 3f);
			num16 = GloabFunc.smethod_0(19, GloabFunc.smethod_1(0, num16));
			if (num12 < 0f)
			{
				vadState_0.negSNRvar = Math.Min(0.99f * vadState_0.negSNRvar + 0.01f * num12 * num12, 4f);
				vadState_0.negSNRbias = Math.Max(12f * (vadState_0.negSNRvar - 0.65f), 0f);
			}
			int result;
			if ((float)num11 > (float)GloabFunc.vm_threshold_table[num16] + vadState_0.negSNRbias)
			{
				result = 1;
				if ((vadState_0.burstcount += 1) > GloabFunc.burstcount_table[num16])
				{
					vadState_0.hangover = GloabFunc.hangover_table[num16];
				}
			}
			else
			{
				vadState_0.burstcount = 0;
				if ((vadState_0.hangover -= 1) <= 0)
				{
					result = 0;
					vadState_0.hangover = 0;
				}
				else
				{
					result = 1;
				}
			}
			for (i = 0; i <= 15; i++)
			{
				array3[i] = 10f * (float)Math.Log10((double)vadState_0.ch_enrg[i]);
			}
			float num17 = 0f;
			if (vadState_0.Lframe_cnt == 1)
			{
				for (i = 0; i <= 15; i++)
				{
					vadState_0.ch_enrg_long_db[i] = array3[i];
				}
			}
			else
			{
				for (i = 0; i <= 15; i++)
				{
					num17 += Math.Abs(vadState_0.ch_enrg_long_db[i] - array3[i]);
				}
			}
			float num18 = vadState_0.tsnr - num12;
			if ((double)num18 > 0.0 && (double)vadState_0.tsnr > 0.0)
			{
				if (num18 > vadState_0.tsnr)
				{
					num = 0.7f;
				}
				else
				{
					num = 0.9f - (float)(0.20000000000000007 * (double)num18 / (double)vadState_0.tsnr);
				}
			}
			else
			{
				num = 0.9f;
			}
			for (i = 0; i <= 15; i++)
			{
				vadState_0.ch_enrg_long_db[i] = num * vadState_0.ch_enrg_long_db[i] + (1f - num) * array3[i];
			}
			int num19 = 0;
			vadState_0.fupdate_flag = 0;
			if (num11 > 35 && (vadState_0.Lframe_cnt > 4 || num9 != 0))
			{
				if ((double)num5 > 0.25 && (double)num17 < 28.0 && num9 == 0 && vadState_0.LTP_flag == 0)
				{
					vadState_0.update_cnt += 1;
					if (vadState_0.update_cnt >= 50)
					{
						num19 = 1;
						vadState_0.fupdate_flag = 1;
					}
				}
			}
			else
			{
				num19 = 1;
				vadState_0.update_cnt = 0;
			}
			if (vadState_0.update_cnt == vadState_0.last_update_cnt)
			{
				vadState_0.hyster_cnt += 1;
			}
			else
			{
				vadState_0.hyster_cnt = 0;
			}
			vadState_0.last_update_cnt = vadState_0.update_cnt;
			if (vadState_0.hyster_cnt > 6)
			{
				vadState_0.update_cnt = 0;
			}
			if (num19 != 0)
			{
				for (i = 0; i <= 15; i++)
				{
					vadState_0.ch_noise[i] = 0.9f * vadState_0.ch_noise[i] + 0.1f * vadState_0.ch_enrg[i];
					if ((double)vadState_0.ch_noise[i] < 0.015625)
					{
						vadState_0.ch_noise[i] = 0.015625f;
					}
				}
			}
			return result;
		}
		private static void real_fft(float[] farray_ptr, int farray_ptrOffset, int isign)
		{
			if (GloabFunc.first == 1)
			{
				GloabFunc.fill_tbl();
				GloabFunc.first = 0;
			}
			float num;
			float num2;
			int i;
			int num3;
			if (isign == 1)
			{
				GloabFunc.cmplx_fft(farray_ptr, farray_ptrOffset, isign);
				num = farray_ptr[farray_ptrOffset];
				num2 = farray_ptr[farray_ptrOffset + 1];
				farray_ptr[farray_ptrOffset] = num + num2;
				farray_ptr[farray_ptrOffset + 1] = num - num2;
				i = 2;
				num3 = 128 - 2;
				while (i <= 64)
				{
					num = farray_ptr[farray_ptrOffset + i] + farray_ptr[farray_ptrOffset + num3];
					float num4 = farray_ptr[farray_ptrOffset + i + 1] - farray_ptr[farray_ptrOffset + num3 + 1];
					num2 = farray_ptr[farray_ptrOffset + i + 1] + farray_ptr[farray_ptrOffset + num3 + 1];
					float num5 = farray_ptr[farray_ptrOffset + num3] - farray_ptr[farray_ptrOffset + i];
					farray_ptr[farray_ptrOffset + i + 1] = (num + (float)GloabFunc.phs_tbl[i] * num2 - (float)GloabFunc.phs_tbl[i + 1] * num5) / 2f;
					farray_ptr[farray_ptrOffset + i + 1] = (num4 + (float)GloabFunc.phs_tbl[i] * num5 + (float)GloabFunc.phs_tbl[i + 1] * num2) / 2f;
					farray_ptr[farray_ptrOffset + num3] = (num + (float)GloabFunc.phs_tbl[num3] * num2 + (float)GloabFunc.phs_tbl[num3 + 1] * num5) / 2f;
					farray_ptr[farray_ptrOffset + num3 + 1] = (-num4 - (float)GloabFunc.phs_tbl[num3] * num5 + (float)GloabFunc.phs_tbl[num3 + 1] * num2) / 2f;
					i += 2;
					num3 = 128 - i;
				}
				return;
			}
			num = farray_ptr[farray_ptrOffset];
			num2 = farray_ptr[farray_ptrOffset + 1];
			farray_ptr[farray_ptrOffset] = (num + num2) / 2f;
			farray_ptr[farray_ptrOffset + 1] = (num - num2) / 2f;
			i = 2;
			num3 = 128 - 2;
			while (i <= 64)
			{
				num = farray_ptr[farray_ptrOffset + i] + farray_ptr[farray_ptrOffset + num3];
				float num4 = farray_ptr[farray_ptrOffset + i + 1] - farray_ptr[farray_ptrOffset + num3 + 1];
				num2 = -farray_ptr[farray_ptrOffset + i + 1] + farray_ptr[farray_ptrOffset + num3 + 1];
				float num5 = -(farray_ptr[farray_ptrOffset + num3] - farray_ptr[farray_ptrOffset + i]);
				farray_ptr[farray_ptrOffset + i] = (num + (float)GloabFunc.phs_tbl[i] * num2 + (float)GloabFunc.phs_tbl[i + 1] * num5) / 2f;
				farray_ptr[farray_ptrOffset + i + 1] = (num4 + (float)GloabFunc.phs_tbl[i] * num5 - (float)GloabFunc.phs_tbl[i + 1] * num2) / 2f;
				farray_ptr[farray_ptrOffset + num3] = (num + (float)GloabFunc.phs_tbl[num3] * num2 - (float)GloabFunc.phs_tbl[num3 + 1] * num5) / 2f;
				farray_ptr[farray_ptrOffset + num3 + 1] = (-num4 - (float)GloabFunc.phs_tbl[num3] * num5 - (float)GloabFunc.phs_tbl[num3 + 1] * num2) / 2f;
				i += 2;
				num3 = 128 - i;
			}
			GloabFunc.cmplx_fft(farray_ptr, farray_ptrOffset, isign);
		}
		private static void cmplx_fft(float[] farray_ptr, int farray_ptrOffset, int isign)
		{
			int i = 0;
			int j = 0;
			while (i < 126)
			{
				if (j > i)
				{
					float num = farray_ptr[farray_ptrOffset + i];
					farray_ptr[farray_ptrOffset + i] = farray_ptr[farray_ptrOffset + j];
					farray_ptr[farray_ptrOffset + j] = num;
					num = farray_ptr[farray_ptrOffset + i + 1];
					farray_ptr[farray_ptrOffset + i + 1] = farray_ptr[farray_ptrOffset + j + 1];
					farray_ptr[farray_ptrOffset + j + 1] = num;
				}
				int k = 64;
				while (j >= k)
				{
					j -= k;
					k >>= 1;
				}
				j += k;
				i += 2;
			}
			if (isign == 1)
			{
				for (i = 0; i < 6; i++)
				{
					int num2 = 2 << i;
					int num3 = num2 << 1;
					int num4 = 128 / num2;
					for (j = 0; j < num2; j += 2)
					{
						int num5 = j * num4;
						for (int k = j; k < 128; k += num3)
						{
							int num6 = k + num2;
							float num7 = farray_ptr[farray_ptrOffset + num6] * (float)GloabFunc.phs_tbl[num5] - farray_ptr[farray_ptrOffset + num6 + 1] * (float)GloabFunc.phs_tbl[num5 + 1];
							float num8 = farray_ptr[farray_ptrOffset + num6 + 1] * (float)GloabFunc.phs_tbl[num5] + farray_ptr[farray_ptrOffset + num6] * (float)GloabFunc.phs_tbl[num5 + 1];
							farray_ptr[farray_ptrOffset + num6] = (farray_ptr[farray_ptrOffset + k] - num7) / 2f;
							farray_ptr[farray_ptrOffset + num6 + 1] = (farray_ptr[farray_ptrOffset + k + 1] - num8) / 2f;
							farray_ptr[farray_ptrOffset + k] = (farray_ptr[farray_ptrOffset + k] + num7) / 2f;
							farray_ptr[farray_ptrOffset + k + 1] = (farray_ptr[farray_ptrOffset + k + 1] + num8) / 2f;
						}
					}
				}
				return;
			}
			for (i = 0; i < 6; i++)
			{
				int num2 = 2 << i;
				int num3 = num2 << 1;
				int num4 = 128 / num2;
				for (j = 0; j < num2; j += 2)
				{
					int num5 = j * num4;
					for (int k = j; k < 128; k += num3)
					{
						int num6 = k + num2;
						float num7 = farray_ptr[farray_ptrOffset + num6] * (float)GloabFunc.phs_tbl[num5] + farray_ptr[farray_ptrOffset + num6 + 1] * (float)GloabFunc.phs_tbl[num5 + 1];
						float num8 = farray_ptr[farray_ptrOffset + num6 + 1] * (float)GloabFunc.phs_tbl[num5] - farray_ptr[farray_ptrOffset + num6] * (float)GloabFunc.phs_tbl[num5 + 1];
						farray_ptr[farray_ptrOffset + num6] = farray_ptr[farray_ptrOffset + k] - num7;
						farray_ptr[farray_ptrOffset + num6 + 1] = farray_ptr[farray_ptrOffset + k + 1] - num8;
						farray_ptr[farray_ptrOffset + k] = farray_ptr[farray_ptrOffset + k] + num7;
						farray_ptr[farray_ptrOffset + k + 1] = farray_ptr[farray_ptrOffset + k + 1] + num8;
					}
				}
			}
		}
		private static void fill_tbl()
		{
			double num = -0.049087385212340517;
			for (int i = 0; i < 64; i++)
			{
				double num2 = num * (double)i;
				GloabFunc.phs_tbl[2 * i] = Math.Cos(num2);
				GloabFunc.phs_tbl[2 * i + 1] = Math.Sin(num2);
			}
		}
		private static void LTP_flag_update(GloabFunc.vadState vadState_0, Mode mode)
		{
			float num;
			if (mode != Mode.MR475)
			{
				if (mode != Mode.MR515)
				{
					if (mode == Mode.MR102)
					{
						num = 0.6f;
						goto IL_23;
					}
					num = 0.65f;
					goto IL_23;
				}
			}
			num = 0.55f;
			IL_23:
			if (vadState_0.Rmax > num * vadState_0.R0)
			{
				vadState_0.LTP_flag = 1;
				return;
			}
			vadState_0.LTP_flag = 0;
		}
		private static void cod_amr(GloabFunc.cod_amrState cod_amrState_0, Mode mode, float[] new_speech, int new_speechOffset, short[] short_0, int anaOffset, ref Mode used_mode, float[] synth, int synthOffset)
		{
			float[] array = new float[44];
			float[] array2 = new float[44];
			float[] array3 = new float[10];
			float[] array4 = new float[40];
			float[] array5 = new float[40];
			float[] array6 = new float[40];
			float[] array7 = new float[40];
			float[] array8 = new float[40];
			float[] gCoeff = new float[3];
			float[] array9 = new float[40];
			float[] array10 = new float[40];
			float[] float_ = new float[40];
			float[] array11 = new float[40];
			float[] array12 = new float[40];
			float[] array13 = new float[40];
			float[] array14 = new float[10];
			float[] array15 = new float[10];
			float[] array16 = new float[10];
			float sharp = 0f;
			float gain_pit = 0f;
			float gain_code = 0f;
			short num = 0;
			float num2 = 0f;
			float gain_code2 = 0f;
			float gp_limit = 0f;
			int t = 0;
			int frac = 0;
			int num3 = 0;
			int num4 = 0;
			int[] array17 = new int[2];
			short lsp_flag = 0;
			GloabFunc.memcpyFloat(cod_amrState_0.new_speech, cod_amrState_0.new_speechOffset, new_speech, new_speechOffset, 160);
			short compute_sid_flag;
			if (cod_amrState_0.int_0 != 0)
			{
				short num5 = (short)GloabFunc.vad2(cod_amrState_0.vadSt, cod_amrState_0.new_speech, cod_amrState_0.new_speechOffset);
				num5 = (short)GloabFunc.bool2int(GloabFunc.vad2(cod_amrState_0.vadSt, cod_amrState_0.new_speech, cod_amrState_0.new_speechOffset + 80) != 0 || num5 != 0);
				if (used_mode < 0)
				{
					num5 = 1;
				}
				used_mode = mode;
				compute_sid_flag = GloabFunc.tx_dtx_handler(num5, ref cod_amrState_0.dtxEncSt.decAnaElapsedCount, ref cod_amrState_0.dtxEncSt.dtxHangoverCount, ref used_mode);
			}
			else
			{
				compute_sid_flag = 0;
				used_mode = mode;
			}
			GloabFunc.smethod_2(cod_amrState_0.lpcSt.LevinsonSt.old_A, 0, cod_amrState_0.p_window, cod_amrState_0.p_windowOffset, cod_amrState_0.p_window_12k2, cod_amrState_0.p_window_12k2Offset, array, 0, mode);
			short num6 = 0;
			GloabFunc.smethod_3(mode, used_mode, cod_amrState_0.lspSt.lsp_old, 0, cod_amrState_0.lspSt.lsp_old_q, 0, cod_amrState_0.lspSt.qSt.past_rq, 0, array, 0, array2, 0, array3, 0, short_0, ref num6);
			anaOffset = (int)num6;
			GloabFunc.dtx_buffer(ref cod_amrState_0.dtxEncSt.hist_ptr, cod_amrState_0.dtxEncSt.lsp_hist, 0, array3, 0, cod_amrState_0.new_speech, cod_amrState_0.new_speechOffset, cod_amrState_0.dtxEncSt.log_en_hist, 0);
			if (used_mode == 8)
			{
				GloabFunc.dtx_enc(ref cod_amrState_0.dtxEncSt.log_en_index, cod_amrState_0.dtxEncSt.log_en_hist, 0, cod_amrState_0.dtxEncSt.lsp_hist, 0, cod_amrState_0.dtxEncSt.lsp_index, 0, ref cod_amrState_0.dtxEncSt.init_lsf_vq_index, compute_sid_flag, cod_amrState_0.lspSt.qSt.past_rq, 0, cod_amrState_0.gainQuantSt.gc_predSt.past_qua_en, 0, ref short_0, ref anaOffset);
				GloabFunc.memsetFloat(cod_amrState_0.old_exc, 0, 0f, 616);
				GloabFunc.memsetFloat(cod_amrState_0.mem_w0, 0, 0f, 40);
				GloabFunc.memsetFloat(cod_amrState_0.mem_err, 0, 0f, 40);
				GloabFunc.memsetFloat(cod_amrState_0.zero, cod_amrState_0.zeroOffset, 0f, 160);
				GloabFunc.memsetFloat(cod_amrState_0.hvec, 0, 0f, 160);
				GloabFunc.memsetFloat(cod_amrState_0.lspSt.qSt.past_rq, 0, 0f, 40);
				GloabFunc.memcpyFloat(cod_amrState_0.lspSt.lsp_old, 0, array3, 0, 10);
				GloabFunc.memcpyFloat(cod_amrState_0.lspSt.lsp_old_q, 0, array3, 0, 10);
				cod_amrState_0.clLtpSt.pitchSt.T0_prev_subframe = 0;
				cod_amrState_0.sharp = 0f;
			}
			else
			{
				lsp_flag = GloabFunc.check_lsp(ref cod_amrState_0.tonStabSt.count, cod_amrState_0.lspSt.lsp_old, 0);
			}
			if (cod_amrState_0.int_0 != 0)
			{
				cod_amrState_0.vadSt.Rmax = 0f;
				cod_amrState_0.vadSt.R0 = 0f;
			}
			short num7 = 0;
			short num8 = 0;
			while (num7 < 2)
			{
				GloabFunc.pre_big(mode, DefineConstants.gamma1, 0, DefineConstants.gamma1_12k2, 0, DefineConstants.gamma2, 0, array, 0, num8, cod_amrState_0.speech, cod_amrState_0.speechOffset, cod_amrState_0.mem_w, 0, cod_amrState_0.float_0, cod_amrState_0.wspOffset);
				if (mode != Mode.MR475 && mode != Mode.MR515)
				{
					GloabFunc.ol_ltp(mode, cod_amrState_0.vadSt, cod_amrState_0.float_0, cod_amrState_0.wspOffset + (int)num8, ref array17[(int)num7], cod_amrState_0.ol_gain_flg, 0, ref cod_amrState_0.pitchOLWghtSt.old_T0_med, ref cod_amrState_0.pitchOLWghtSt.wght_flg, ref cod_amrState_0.pitchOLWghtSt.ada_w, cod_amrState_0.old_lags, 0, cod_amrState_0.int_0, num7);
				}
				num7 += 1;
				num8 += 80;
			}
			if (mode == Mode.MR475 || mode == Mode.MR515)
			{
				GloabFunc.ol_ltp(mode, cod_amrState_0.vadSt, cod_amrState_0.float_0, cod_amrState_0.wspOffset, ref array17[0], cod_amrState_0.ol_gain_flg, 0, ref cod_amrState_0.pitchOLWghtSt.old_T0_med, ref cod_amrState_0.pitchOLWghtSt.wght_flg, ref cod_amrState_0.pitchOLWghtSt.ada_w, cod_amrState_0.old_lags, 0, cod_amrState_0.int_0, 1);
				array17[1] = array17[0];
			}
			if (cod_amrState_0.int_0 != 0)
			{
				GloabFunc.LTP_flag_update(cod_amrState_0.vadSt, mode);
			}
			if (used_mode != 8)
			{
				float[] a = array;
				int num9 = 0;
				float[] array18 = array2;
				int num10 = 0;
				int num11 = 0;
				num7 = -1;
				for (num8 = 0; num8 < 160; num8 += 40)
				{
					num7 += 1;
					num11 = 1 - num11;
					if (num11 != 0 && used_mode == 0)
					{
						GloabFunc.memcpyFloat(array14, 0, cod_amrState_0.mem_syn, 0, 10);
						GloabFunc.memcpyFloat(array15, 0, cod_amrState_0.mem_w0, 0, 10);
						GloabFunc.memcpyFloat(array16, 0, cod_amrState_0.mem_err, 0, 10);
						sharp = cod_amrState_0.sharp;
					}
					if (used_mode != 0)
					{
						GloabFunc.subframePreProc(used_mode, DefineConstants.gamma1, 0, DefineConstants.gamma1_12k2, 0, DefineConstants.gamma2, 0, a, num9, array18, num10, cod_amrState_0.speech, cod_amrState_0.speechOffset + (int)num8, cod_amrState_0.mem_err, 0, cod_amrState_0.mem_w0, 0, cod_amrState_0.zero, cod_amrState_0.zeroOffset, cod_amrState_0.ai_zero, 0, cod_amrState_0.float_1, cod_amrState_0.excOffset + (int)num8, cod_amrState_0.float_2, cod_amrState_0.h1Offset, array4, 0, array9, 0, cod_amrState_0.error, cod_amrState_0.errorOffset);
					}
					else
					{
						GloabFunc.subframePreProc(used_mode, DefineConstants.gamma1, 0, DefineConstants.gamma1_12k2, 0, DefineConstants.gamma2, 0, a, num9, array18, num10, cod_amrState_0.speech, cod_amrState_0.speechOffset + (int)num8, cod_amrState_0.mem_err, 0, array15, 0, cod_amrState_0.zero, cod_amrState_0.zeroOffset, cod_amrState_0.ai_zero, 0, cod_amrState_0.float_1, cod_amrState_0.excOffset + (int)num8, cod_amrState_0.float_2, cod_amrState_0.h1Offset, array4, 0, array9, 0, cod_amrState_0.error, cod_amrState_0.errorOffset);
						if (num11 != 0)
						{
							GloabFunc.memcpyFloat(array13, 0, cod_amrState_0.float_2, cod_amrState_0.h1Offset, 40);
						}
					}
					GloabFunc.memcpyFloat(array10, 0, array9, 0, 40);
					GloabFunc.cl_ltp(ref cod_amrState_0.clLtpSt.pitchSt.T0_prev_subframe, cod_amrState_0.tonStabSt.float_0, 0, used_mode, num8, array17, 0, cod_amrState_0.float_2, cod_amrState_0.h1Offset, cod_amrState_0.float_1, cod_amrState_0.excOffset + (int)num8, array10, 0, array4, 0, lsp_flag, array5, 0, array7, 0, ref num3, ref num4, ref num2, gCoeff, 0, short_0, ref anaOffset, ref gp_limit);
					if (num7 == 0 && cod_amrState_0.ol_gain_flg[0] > 0f)
					{
						cod_amrState_0.old_lags[1] = num3;
					}
					if (num7 == 3 && cod_amrState_0.ol_gain_flg[1] > 0f)
					{
						cod_amrState_0.old_lags[0] = num3;
					}
					GloabFunc.cbsearch(used_mode, num7, array5, 0, cod_amrState_0.float_2, cod_amrState_0.h1Offset, num3, cod_amrState_0.sharp, num2, array6, 0, array8, 0, array10, 0, ref short_0, ref anaOffset);
					GloabFunc.gainQuant(used_mode, num11, cod_amrState_0.gainQuantSt.gc_predSt.past_qua_en, 0, cod_amrState_0.gainQuantSt.gc_predUncSt.past_qua_en, 0, cod_amrState_0.gainQuantSt.sf0_coeff, 0, ref cod_amrState_0.gainQuantSt.sf0_target_en, ref cod_amrState_0.gainQuantSt.sf0_gcode0_exp, ref cod_amrState_0.gainQuantSt.sf0_gcode0_fra, ref cod_amrState_0.gainQuantSt.gain_idx_ptr, ref cod_amrState_0.gainQuantSt.gain_idx_ptrOffset, ref gain_pit, ref gain_code, array9, 0, cod_amrState_0.float_1, cod_amrState_0.excOffset + (int)num8, array6, 0, array4, 0, array5, 0, array7, 0, array8, 0, gCoeff, 0, gp_limit, ref num2, ref gain_code2, ref cod_amrState_0.gainQuantSt.adaptSt.prev_gc, ref cod_amrState_0.gainQuantSt.adaptSt.onset, cod_amrState_0.gainQuantSt.adaptSt.ltpg_mem, 0, ref cod_amrState_0.gainQuantSt.adaptSt.prev_alpha, ref short_0, ref anaOffset);
					for (int i = 0; i < 6; i++)
					{
						cod_amrState_0.tonStabSt.float_0[i] = cod_amrState_0.tonStabSt.float_0[i + 1];
					}
					cod_amrState_0.tonStabSt.float_0[6] = num2;
					if (used_mode != 0)
					{
						GloabFunc.subframePostProc(cod_amrState_0.speech, cod_amrState_0.speechOffset, num8, num2, gain_code2, array18, num10, synth, synthOffset, array4, 0, array6, 0, array7, 0, array8, 0, cod_amrState_0.mem_syn, 0, cod_amrState_0.mem_err, 0, cod_amrState_0.mem_w0, 0, cod_amrState_0.float_1, cod_amrState_0.excOffset, ref cod_amrState_0.sharp);
					}
					else
					{
						if (num11 != 0)
						{
							num = num8;
							GloabFunc.memcpyFloat(float_, 0, array4, 0, 40);
							GloabFunc.memcpyFloat(array11, 0, array8, 0, 40);
							GloabFunc.memcpyFloat(array12, 0, array6, 0, 40);
							t = num3;
							frac = num4;
							GloabFunc.subframePostProc(cod_amrState_0.speech, cod_amrState_0.speechOffset, num8, num2, gain_code2, array18, num10, synth, synthOffset, array4, 0, array6, 0, array7, 0, array8, 0, array14, 0, cod_amrState_0.mem_err, 0, array15, 0, cod_amrState_0.float_1, cod_amrState_0.excOffset, ref cod_amrState_0.sharp);
							cod_amrState_0.sharp = sharp;
						}
						else
						{
							GloabFunc.memcpyFloat(cod_amrState_0.mem_err, 0, array16, 0, 10);
							GloabFunc.Pred_lt_3or6(cod_amrState_0.float_1, cod_amrState_0.excOffset + (int)num, t, frac, 1);
							GloabFunc.Convolve(cod_amrState_0.float_1, cod_amrState_0.excOffset + (int)num, array13, 0, array7, 0);
							num10 -= 11;
							GloabFunc.subframePostProc(cod_amrState_0.speech, cod_amrState_0.speechOffset, num, gain_pit, gain_code, array18, num10, synth, synthOffset, float_, 0, array12, 0, array7, 0, array11, 0, cod_amrState_0.mem_syn, 0, cod_amrState_0.mem_err, 0, cod_amrState_0.mem_w0, 0, cod_amrState_0.float_1, cod_amrState_0.excOffset, ref sharp);
							num10 += 11;
							GloabFunc.subframePreProc(used_mode, DefineConstants.gamma1, 0, DefineConstants.gamma1_12k2, 0, DefineConstants.gamma2, 0, a, num9, array18, num10, cod_amrState_0.speech, cod_amrState_0.speechOffset + (int)num8, cod_amrState_0.mem_err, 0, cod_amrState_0.mem_w0, 0, cod_amrState_0.zero, cod_amrState_0.zeroOffset, cod_amrState_0.ai_zero, 0, cod_amrState_0.float_1, cod_amrState_0.excOffset + (int)num8, cod_amrState_0.float_2, cod_amrState_0.h1Offset, array4, 0, array9, 0, cod_amrState_0.error, cod_amrState_0.errorOffset);
							GloabFunc.Pred_lt_3or6(cod_amrState_0.float_1, cod_amrState_0.excOffset + (int)num8, num3, num4, 1);
							GloabFunc.Convolve(cod_amrState_0.float_1, cod_amrState_0.excOffset + (int)num8, cod_amrState_0.float_2, cod_amrState_0.h1Offset, array7, 0);
							GloabFunc.subframePostProc(cod_amrState_0.speech, cod_amrState_0.speechOffset, num8, num2, gain_code2, array18, num10, synth, synthOffset, array4, 0, array6, 0, array7, 0, array8, 0, cod_amrState_0.mem_syn, 0, cod_amrState_0.mem_err, 0, cod_amrState_0.mem_w0, 0, cod_amrState_0.float_1, cod_amrState_0.excOffset, ref cod_amrState_0.sharp);
						}
					}
					num9 += 11;
					num10 += 11;
				}
			}
			for (int i = 0; i < 143; i++)
			{
				cod_amrState_0.old_wsp[i] = cod_amrState_0.old_wsp[160 + i];
			}
			for (int i = 0; i < 154; i++)
			{
				cod_amrState_0.old_exc[i] = cod_amrState_0.old_exc[160 + i];
			}
			for (int i = 0; i < 160; i++)
			{
				cod_amrState_0.old_speech[i] = cod_amrState_0.old_speech[160 + i];
			}
		}
		private static int Pre_Process_reset(GloabFunc.Pre_ProcessState state)
		{
			if (state == null)
			{
				return -1;
			}
			state.float_0 = 0f;
			state.float_1 = 0f;
			state.float_2 = 0f;
			state.float_3 = 0f;
			return 0;
		}
		private static void Pre_Process_exit(ref GloabFunc.Pre_ProcessState state)
		{
			if (state == null)
			{
				return;
			}
			state = null;
		}
		private static int Pre_Process_init(ref GloabFunc.Pre_ProcessState state)
		{
			GloabFunc.Pre_ProcessState pre_ProcessState = new GloabFunc.Pre_ProcessState();
			if (pre_ProcessState == null)
			{
				return -1;
			}
			GloabFunc.Pre_Process_reset(pre_ProcessState);
			state = pre_ProcessState;
			return 0;
		}
		private static void Pre_Process(ref float float_0, ref float float_1, ref float float_2, ref float float_3, short[] speech, int speechOffset, float[] f_speech, int f_speechOffset)
		{
			for (int i = 0; i < 160; i++)
			{
				float num = float_3;
				float_3 = float_2;
				float_2 = (float)speech[speechOffset + i];
				float num2 = (float)(0.4636230465 * (double)float_2 - 0.92724705 * (double)float_3 + 0.4636234515 * (double)num + 1.906005859 * (double)float_1 - 0.911376953 * (double)float_0);
				f_speech[f_speechOffset + i] = num2;
				float_0 = float_1;
				float_1 = num2;
			}
			if ((double)(Math.Abs(float_1) + Math.Abs(float_0)) < 1E-10)
			{
				float_0 = (float_1 = 0f);
			}
		}
		private static void cod_amr_reset(GloabFunc.cod_amrState cod_amrState_0, int int_0)
		{
			cod_amrState_0.int_0 = int_0;
			cod_amrState_0.clLtpSt.pitchSt.T0_prev_subframe = 0;
			GloabFunc.memsetFloat(cod_amrState_0.lspSt.qSt.past_rq, 0, 0f, 40);
			GloabFunc.memcpyFloat(cod_amrState_0.lspSt.lsp_old, 0, DefineConstants.lsp_init_data, 0, DefineConstants.lsp_init_data.Length);
			GloabFunc.memcpyFloat(cod_amrState_0.lspSt.lsp_old_q, 0, DefineConstants.lsp_init_data, 0, DefineConstants.lsp_init_data.Length);
			for (int i = 0; i < 4; i++)
			{
				cod_amrState_0.gainQuantSt.gc_predSt.past_qua_en[i] = 783;
				cod_amrState_0.gainQuantSt.gc_predUncSt.past_qua_en[i] = 783;
			}
			cod_amrState_0.gainQuantSt.adaptSt.onset = 0;
			cod_amrState_0.gainQuantSt.adaptSt.prev_alpha = 0f;
			cod_amrState_0.gainQuantSt.adaptSt.prev_gc = 0f;
			GloabFunc.memsetFloat(cod_amrState_0.gainQuantSt.adaptSt.ltpg_mem, 0, 0f, 20);
			cod_amrState_0.gainQuantSt.sf0_gcode0_exp = 0;
			cod_amrState_0.gainQuantSt.sf0_gcode0_fra = 0;
			cod_amrState_0.gainQuantSt.sf0_target_en = 0f;
			GloabFunc.memsetFloat(cod_amrState_0.gainQuantSt.sf0_coeff, 0, 0f, 20);
			cod_amrState_0.gainQuantSt.gain_idx_ptr = null;
			cod_amrState_0.gainQuantSt.gain_idx_ptrOffset = 0;
			cod_amrState_0.pitchOLWghtSt.old_T0_med = 40;
			cod_amrState_0.pitchOLWghtSt.ada_w = 0f;
			cod_amrState_0.pitchOLWghtSt.wght_flg = 0;
			cod_amrState_0.tonStabSt.count = 0;
			GloabFunc.memsetFloat(cod_amrState_0.tonStabSt.float_0, 0, 0f, 28);
			cod_amrState_0.lpcSt.LevinsonSt.old_A[0] = 1f;
			GloabFunc.memsetFloat(cod_amrState_0.lpcSt.LevinsonSt.old_A, 1, 0f, 40);
			cod_amrState_0.vadSt.pre_emp_mem = 0f;
			cod_amrState_0.vadSt.update_cnt = 0;
			cod_amrState_0.vadSt.hyster_cnt = 0;
			cod_amrState_0.vadSt.last_update_cnt = 0;
			for (int i = 0; i < 16; i++)
			{
				cod_amrState_0.vadSt.ch_enrg_long_db[i] = 0f;
				cod_amrState_0.vadSt.ch_enrg[i] = 0f;
				cod_amrState_0.vadSt.ch_noise[i] = 0f;
			}
			cod_amrState_0.vadSt.Lframe_cnt = 0;
			cod_amrState_0.vadSt.tsnr = 0f;
			cod_amrState_0.vadSt.hangover = 0;
			cod_amrState_0.vadSt.burstcount = 0;
			cod_amrState_0.vadSt.fupdate_flag = 0;
			cod_amrState_0.vadSt.negSNRvar = 0f;
			cod_amrState_0.vadSt.negSNRbias = 0f;
			cod_amrState_0.vadSt.R0 = 0f;
			cod_amrState_0.vadSt.Rmax = 0f;
			cod_amrState_0.vadSt.LTP_flag = 0;
			cod_amrState_0.dtxEncSt.hist_ptr = 0;
			cod_amrState_0.dtxEncSt.log_en_index = 0;
			cod_amrState_0.dtxEncSt.init_lsf_vq_index = 0;
			cod_amrState_0.dtxEncSt.lsp_index[0] = 0;
			cod_amrState_0.dtxEncSt.lsp_index[1] = 0;
			cod_amrState_0.dtxEncSt.lsp_index[2] = 0;
			for (int i = 0; i < 8; i++)
			{
				GloabFunc.memcpyFloat(cod_amrState_0.dtxEncSt.lsp_hist, i * 10, DefineConstants.lsp_init_data, 0, 10);
			}
			GloabFunc.memsetFloat(cod_amrState_0.dtxEncSt.log_en_hist, 0, 0f, 32);
			cod_amrState_0.dtxEncSt.dtxHangoverCount = 7;
			cod_amrState_0.dtxEncSt.decAnaElapsedCount = 30;
			cod_amrState_0.new_speech = cod_amrState_0.old_speech;
			cod_amrState_0.new_speechOffset = 160;
			cod_amrState_0.speech = cod_amrState_0.new_speech;
			cod_amrState_0.speechOffset = cod_amrState_0.new_speechOffset - 40;
			cod_amrState_0.p_window = cod_amrState_0.old_speech;
			cod_amrState_0.p_windowOffset = 80;
			cod_amrState_0.p_window_12k2 = cod_amrState_0.p_window;
			cod_amrState_0.p_window_12k2Offset = cod_amrState_0.p_windowOffset - 40;
			cod_amrState_0.float_0 = cod_amrState_0.old_wsp;
			cod_amrState_0.wspOffset = 143;
			cod_amrState_0.float_1 = cod_amrState_0.old_exc;
			cod_amrState_0.excOffset = 154;
			cod_amrState_0.zero = cod_amrState_0.ai_zero;
			cod_amrState_0.zeroOffset = 11;
			cod_amrState_0.error = cod_amrState_0.mem_err;
			cod_amrState_0.errorOffset = 10;
			cod_amrState_0.float_2 = cod_amrState_0.hvec;
			cod_amrState_0.h1Offset = 40;
			GloabFunc.memsetFloat(cod_amrState_0.old_speech, 0, 0f, 1280);
			GloabFunc.memsetFloat(cod_amrState_0.old_exc, 0, 0f, 616);
			GloabFunc.memsetFloat(cod_amrState_0.old_wsp, 0, 0f, 572);
			GloabFunc.memsetFloat(cod_amrState_0.mem_syn, 0, 0f, 40);
			GloabFunc.memsetFloat(cod_amrState_0.mem_w, 0, 0f, 40);
			GloabFunc.memsetFloat(cod_amrState_0.mem_w0, 0, 0f, 40);
			GloabFunc.memsetFloat(cod_amrState_0.mem_err, 0, 0f, 200);
			GloabFunc.memsetFloat(cod_amrState_0.ai_zero, 0, 0f, 160);
			GloabFunc.memsetFloat(cod_amrState_0.hvec, 0, 0f, 160);
			for (int i = 0; i < 5; i++)
			{
				cod_amrState_0.old_lags[i] = 40;
			}
			cod_amrState_0.sharp = 0f;
		}
		private static int cod_amr_init(ref GloabFunc.cod_amrState state, int int_0)
		{
			GloabFunc.cod_amrState cod_amrState = new GloabFunc.cod_amrState();
			if (cod_amrState == null)
			{
				return -1;
			}
			cod_amrState.clLtpSt = new GloabFunc.clLtpState();
			cod_amrState.clLtpSt.pitchSt = new GloabFunc.Pitch_frState();
			cod_amrState.lspSt = new GloabFunc.lspState();
			cod_amrState.lspSt.qSt = new GloabFunc.Q_plsfState();
			cod_amrState.gainQuantSt = new GloabFunc.gainQuantState();
			cod_amrState.gainQuantSt.gc_predSt = new GloabFunc.gc_predState();
			cod_amrState.gainQuantSt.gc_predUncSt = new GloabFunc.gc_predState();
			cod_amrState.gainQuantSt.adaptSt = new GloabFunc.gain_adaptState();
			cod_amrState.pitchOLWghtSt = new GloabFunc.pitchOLWghtState();
			cod_amrState.tonStabSt = new GloabFunc.tonStabState();
			cod_amrState.lpcSt = new GloabFunc.lpcState();
			cod_amrState.lpcSt.LevinsonSt = new GloabFunc.LevinsonState();
			cod_amrState.vadSt = new GloabFunc.vadState();
			cod_amrState.dtxEncSt = new GloabFunc.dtx_encState();
			GloabFunc.cod_amr_reset(cod_amrState, int_0);
			state = cod_amrState;
			return 0;
		}
		private static void cod_amr_exit(GloabFunc.cod_amrState state)
		{
			if (state == null)
			{
				return;
			}
			state = null;
		}
		private static object Speech_Encode_Frame_init(int int_0)
		{
			GloabFunc.Speech_Encode_FrameState speech_Encode_FrameState = new GloabFunc.Speech_Encode_FrameState();
			speech_Encode_FrameState.cod_amr_state = null;
			speech_Encode_FrameState.int_0 = int_0;
			if (GloabFunc.Pre_Process_init(ref speech_Encode_FrameState.pre_state) == 0 && GloabFunc.cod_amr_init(ref speech_Encode_FrameState.cod_amr_state, int_0) == 0)
			{
				return speech_Encode_FrameState;
			}
			GloabFunc.Speech_Encode_Frame_exit(speech_Encode_FrameState);
			return null;
		}
		private static int Speech_Encode_Frame_reset(object object_0, int int_0)
		{
			GloabFunc.Speech_Encode_FrameState speech_Encode_FrameState = (GloabFunc.Speech_Encode_FrameState)object_0;
			if (speech_Encode_FrameState == null)
			{
				return -1;
			}
			GloabFunc.Pre_Process_reset(speech_Encode_FrameState.pre_state);
			GloabFunc.cod_amr_reset(speech_Encode_FrameState.cod_amr_state, int_0);
			return 0;
		}
		private static void Speech_Encode_Frame_exit(object object_0)
		{
			if ((GloabFunc.Speech_Encode_FrameState)object_0 == null)
			{
				return;
			}
			GloabFunc.Pre_Process_exit(ref ((GloabFunc.Speech_Encode_FrameState)object_0).pre_state);
			GloabFunc.cod_amr_exit(((GloabFunc.Speech_Encode_FrameState)object_0).cod_amr_state);
			object_0 = null;
		}
		private static void Speech_Encode_Frame(object object_0, Mode mode, short[] new_speech, int new_speechOffset, short[] short_0, int prmOffset, ref Mode used_mode)
		{
			float[] synth = new float[160];
			float[] array = new float[160];
			GloabFunc.Speech_Encode_FrameState speech_Encode_FrameState = (GloabFunc.Speech_Encode_FrameState)object_0;
			for (int i = 0; i < 160; i++)
			{
				new_speech[new_speechOffset + i] = (short)((int)new_speech[new_speechOffset + i] & 65528);
			}
			GloabFunc.Pre_Process(ref speech_Encode_FrameState.pre_state.float_0, ref speech_Encode_FrameState.pre_state.float_1, ref speech_Encode_FrameState.pre_state.float_2, ref speech_Encode_FrameState.pre_state.float_3, new_speech, new_speechOffset, array, 0);
			GloabFunc.cod_amr(speech_Encode_FrameState.cod_amr_state, mode, array, 0, short_0, prmOffset, ref used_mode, synth, 0);
		}
		private static double frexp(double double_0, ref int int_0)
		{
			double num = double_0;
			if (double_0 < 0.0)
			{
				double_0 = -1.0 * double_0;
			}
			double num2 = Math.Log(double_0, 2.0);
			num2 += 1.0;
			int_0 = (int)Math.Floor(num2);
			return num / Math.Pow(2.0, (double)int_0);
		}
	}
}
